/* ==========================================================================
   Theme — beige scholarly journal + crystal snow globe centerpiece
   ========================================================================== */

:root {
  --bg:           #ECE7DC;
  --bg-soft:      #E5E0D5;
  --ink:          #2A2724;
  --ink-soft:     #6B6660;
  --ink-faint:    #97928B;
  --accent:       #B65A3E;
  --link:         #2A2724;
  --scene-night:  #0F1B33;
  --globe-edge:   #fff8e6;

  --serif: "Source Serif Pro", "Iowan Old Style", "Times New Roman", "Songti SC", "STSong", serif;
  --mono:  "JetBrains Mono", "IBM Plex Mono", "DejaVu Sans Mono", ui-monospace, Consolas, monospace;

  --measure: 640px;
  --gutter:  clamp(1.25rem, 3vw, 2.5rem);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--link);
  text-decoration: none;
  border-bottom: 1px solid currentColor;
  transition: color 160ms ease, border-color 160ms ease;
}
a:hover { color: var(--accent); border-color: var(--accent); }

button { font: inherit; }

/* ==========================================================================
   Top bar
   ========================================================================== */

.top-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 1.6rem var(--gutter);
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
}
.top-bar .date     { justify-self: start; }
.top-bar .masthead { justify-self: center; color: var(--ink-soft); }
.top-bar__right    { justify-self: end; }

.lang-toggle {
  background: transparent;
  border: 1px solid var(--ink-faint);
  color: var(--ink-soft);
  font: inherit;
  letter-spacing: 0.06em;
  padding: 0.25rem 0.6rem;
  cursor: pointer;
  border-radius: 2px;
}
.lang-toggle:hover { color: var(--bg); background: var(--ink); border-color: var(--ink); }

/* ==========================================================================
   Container
   ========================================================================== */

.container {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 2.5rem var(--gutter) 6rem;
}

.section-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 1.25rem;
  letter-spacing: 0.02em;
}
.lead {
  font-size: 1.02rem;
  margin: 0 0 1.5rem;
}

.socials {
  list-style: none;
  padding: 0; margin: 0 0 3rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--ink-soft);
}
.socials a { border-bottom-style: dotted; }

/* ==========================================================================
   Crystal snow globe
   ========================================================================== */

.globe {
  position: relative;
  margin: 0 auto;
  width: min(560px, 92%);
  display: grid;
  justify-items: center;
  padding-bottom: 2rem;
  cursor: default;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
/* hide the system cursor over the orb's disk — the canvas draws its own glowing cross instead */
.globe.is-inside,
.globe.is-inside * {
  cursor: none;
}

.globe__sphere {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: radial-gradient(circle at 50% 35%, #182a4f 0%, #050a18 70%);
  /* Edge softness: a wide gradient mask so the orb fades continuously
     from the center outward — no visible boundary, just a misty halo
     bleeding into the background. */
  -webkit-mask-image: radial-gradient(circle closest-side at 50% 50%,
    #000 0%,
    #000 42%,
    rgba(0,0,0,0.95) 56%,
    rgba(0,0,0,0.82) 70%,
    rgba(0,0,0,0.55) 82%,
    rgba(0,0,0,0.28) 92%,
    rgba(0,0,0,0.10) 97%,
    transparent 100%);
          mask-image: radial-gradient(circle closest-side at 50% 50%,
    #000 0%,
    #000 42%,
    rgba(0,0,0,0.95) 56%,
    rgba(0,0,0,0.82) 70%,
    rgba(0,0,0,0.55) 82%,
    rgba(0,0,0,0.28) 92%,
    rgba(0,0,0,0.10) 97%,
    transparent 100%);
  /* Layered drop-shadows respect the post-mask shape, so the soft halo
     follows the misty fade out into the page. */
  filter:
    drop-shadow(0 0 24px rgba(30, 40, 70, 0.30))
    drop-shadow(0 0 60px rgba(30, 40, 70, 0.18))
    drop-shadow(0 18px 32px rgba(8, 14, 30, 0.35));
  transform: rotate(0deg);
  will-change: transform;
}

/* ----------------------------------------------------------------------
   Rolling layer — the night sky and stars and atmospheric haze tilt
   with the ball. Snow stays in screen-space (real-world gravity).
   ---------------------------------------------------------------------- */
.globe__roll {
  position: absolute;
  inset: 0;
  transform: rotate(0deg);
  will-change: transform;
}

.globe__video {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  transform: scale(1.06);
  filter: brightness(0.92) saturate(1.05) contrast(1.02);
}

/* starfield canvas — dense night-sky points scattered through the orb,
   twinkling in place. Lives inside the rolling layer so it tilts with the ball. */
.globe__stars {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}

/* atmospheric haze — center clear, dark navy at the edges */
.globe__atmo {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 50%,
      rgba(10, 20, 40, 0)    0%,
      rgba(10, 20, 40, 0)    22%,
      rgba(10, 20, 40, 0.18) 42%,
      rgba(10, 20, 40, 0.42) 60%,
      rgba(7,  14, 30, 0.70) 78%,
      rgba(4,   8, 20, 0.92) 92%,
      rgba(0,   0,  0, 1)   100%);
}

.globe__snow {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}

/* very subtle glossy highlight — fixed light source, doesn't rotate */
.globe__gloss {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 45% 28% at 30% 20%,
      rgba(255,255,255,0.20) 0%, rgba(255,255,255,0) 60%),
    radial-gradient(circle 4% at 24% 28%,
      rgba(255,255,255,0.55) 0%, rgba(255,255,255,0) 65%);
  mix-blend-mode: screen;
}

.globe__base {
  margin-top: -8%;
  width: 55%;
  height: 18px;
  background: linear-gradient(180deg, #6e5a48 0%, #4b3c30 100%);
  border-radius: 6px 6px 12px 12px / 6px 6px 24px 24px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.18),
    inset 0 -2px 4px rgba(0,0,0,0.35),
    0 6px 14px -4px rgba(0,0,0,0.35);
  position: relative;
  z-index: -1;
}

.globe__shadow {
  margin-top: 6px;
  width: 50%;
  height: 14px;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0) 70%);
  filter: blur(2px);
}

.globe__hint {
  display: block;
  margin-top: 1.25rem;
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.05em;
  color: var(--ink-faint);
  opacity: 0.75;
  transition: opacity 220ms ease;
}
.globe.is-touched .globe__hint { opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  .globe__roll { transition: none; }
}

/* ==========================================================================
   Numbered blocks
   ========================================================================== */

.block { margin: 4.5rem 0; }
.block__head {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.75rem;
}
.block__num {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-faint);
  letter-spacing: 0.06em;
}
.block__title {
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  margin: 0;
  color: var(--ink-soft);
}
.block__rule { height: 1px; background: var(--bg-soft); }

.entries {
  list-style: none;
  margin: 0; padding: 0;
  display: grid;
  gap: 1.6rem;
}

.entry__row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 0.75rem;
}

.entry__title {
  display: inline-block;
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 0.25rem;
  border-bottom: 1px solid var(--ink);
  cursor: pointer;
  background: none;
  border-top: none; border-left: none; border-right: none;
  padding: 0;
  color: var(--ink);
  text-align: left;
  transition: color 160ms ease, border-color 160ms ease, transform 160ms ease;
}
.entry__title:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: translateX(3px);
}

.entry__desc {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.97rem;
}

.entries-empty {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--ink-faint);
  font-style: italic;
  padding: 0.6rem 0;
  border-top: 1px dashed var(--bg-soft);
  border-bottom: 1px dashed var(--bg-soft);
  text-align: center;
}

/* ==========================================================================
   Contact
   ========================================================================== */

.contact { margin-top: 5rem; }
.contact__lead {
  color: var(--ink-soft);
  margin-bottom: 0.5rem;
  font-size: 0.97rem;
}
.contact__email {
  font-family: var(--mono);
  font-size: 0.95rem;
  margin: 0;
}
.contact__email a { border-bottom-style: dotted; }
.contact__email a:empty::before {
  content: "your@email.com";
  opacity: 0.4;
  font-style: italic;
}

/* ==========================================================================
   Detail view
   ========================================================================== */

.detail {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 80;
  overflow-y: auto;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 280ms ease, transform 280ms ease;
  pointer-events: none;
}
.detail.is-open {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.detail__bar {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem var(--gutter);
  background: var(--bg);
  border-bottom: 1px solid var(--bg-soft);
  font-family: var(--mono);
  font-size: 0.82rem;
}
.detail__back {
  border-bottom: none;
  color: var(--ink-soft);
}
.detail__back:hover { color: var(--accent); }
.detail__crumb {
  color: var(--ink-faint);
  letter-spacing: 0.04em;
}

.detail__article {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 3rem var(--gutter) 6rem;
}
.detail__title {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 600;
  margin: 0 0 0.75rem;
  letter-spacing: -0.005em;
}
.detail__desc {
  color: var(--ink-soft);
  font-size: 1.05rem;
  margin: 0 0 2.25rem;
}
.detail__body {
  font-size: 1.02rem;
}
.detail__body p {
  margin: 0 0 1.1rem;
}
.detail__body h1,
.detail__body h2,
.detail__body h3,
.detail__body h4 {
  font-weight: 600;
  letter-spacing: -0.005em;
  margin: 1.8rem 0 0.75rem;
}
.detail__body h1 { font-size: 1.5rem; }
.detail__body h2 { font-size: 1.25rem; }
.detail__body h3 { font-size: 1.08rem; }
.detail__body h4 { font-size: 1rem; color: var(--ink-soft); }
.detail__body ul,
.detail__body ol {
  margin: 0 0 1.1rem;
  padding-left: 1.4rem;
}
.detail__body li { margin: 0.25rem 0; }
.detail__body blockquote {
  margin: 0 0 1.1rem;
  padding: 0.1rem 0 0.1rem 1rem;
  border-left: 3px solid var(--bg-soft);
  color: var(--ink-soft);
  font-style: italic;
}
.detail__body code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--bg-soft);
  padding: 0.05em 0.35em;
  border-radius: 3px;
}
.detail__body a {
  border-bottom: 1px dotted currentColor;
}

/* ==========================================================================
   Reveal on scroll
   ========================================================================== */

.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 700ms ease, transform 700ms ease;
}
.reveal.is-in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
}

/* ==========================================================================
   Small screens
   ========================================================================== */

@media (max-width: 520px) {
  html, body { font-size: 16px; }
  .top-bar { grid-template-columns: 1fr auto; }
  .top-bar .masthead { display: none; }
}
