/* ==========================================================================
   SAN WRITES — design tokens
   --------------------------------------------------------------------------
   color   bg #0b0a08 / bg-2 #141212 / ink #ece3d4 / ink-dim #a89a89
           wine #6d2a3a / plum #4a3350 / cyan #8fd0c8 / leaf #8f3a2b
   type    display: "Cormorant Garamond" (italic for emphasis)
           body:    "EB Garamond"
           utility: "Inter" (small caps / wide tracking, nav + labels)
   ========================================================================== */

:root {
  --bg: #0b0a08;
  --bg-2: #131110;
  --ink: #ece3d4;
  --ink-dim: #a89a89;
  --ink-faint: #6f6558;
  --wine: #8a3f4f;
  --wine-deep: #4a1f28;
  --plum: #5b3f66;
  --cyan: #8fd0c8;
  --leaf: #a84a37;
  --line: rgba(236, 227, 212, 0.1);

  --display: "Cormorant Garamond", "Times New Roman", serif;
  --body: "EB Garamond", Georgia, serif;
  --sans: "Inter", -apple-system, sans-serif;

  --ease: cubic-bezier(.22,.61,.36,1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; overflow-x: clip; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

::selection { background: var(--wine-deep); color: var(--ink); }

/* focus visibility, kept quiet but present */
a:focus-visible,
button:focus-visible {
  outline: 1px solid var(--cyan);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ==========================================================================
   Entry gate — click to enter, doubles as the user-gesture that
   unlocks audio playback
   ========================================================================== */

.site-content {
  transition: filter 1.1s var(--ease);
}
.site-content.is-blurred {
  filter: blur(22px) brightness(0.85);
  pointer-events: none;
  user-select: none;
}

body.gate-open {
  overflow: hidden;
}

.gate {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(8, 6, 5, 0.42);
  transition: opacity .9s var(--ease), visibility .9s var(--ease);
}
.gate.is-closed {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.gate__inner {
  position: relative;
  text-align: center;
  max-width: 380px;
  padding: 56px 40px;
}
.gate__inner::before {
  content: "";
  position: absolute;
  inset: -20px;
  z-index: -1;
  background: radial-gradient(ellipse at center, rgba(7,6,5,0.65) 0%, rgba(7,6,5,0.32) 55%, transparent 78%);
}

.gate__mark {
  display: block;
  width: 38px;
  height: 38px;
  margin: 0 auto 26px;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  filter: saturate(0.7) brightness(0.85);
  border: 1px solid rgba(236,227,212,0.25);
}

.gate__eyebrow {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 24px;
}

.gate__line {
  font-family: var(--display);
  font-style: italic;
  font-weight: 300;
  font-size: clamp(1.35rem, 3.4vw, 1.75rem);
  line-height: 1.55;
  color: var(--ink);
  margin: 0 0 36px;
}

.gate__enter {
  font-family: var(--sans);
  font-size: 11.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-dim);
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 13px 38px;
  cursor: pointer;
  transition: color .35s var(--ease), border-color .35s var(--ease), background .35s var(--ease);
}
.gate__enter:hover,
.gate__enter:focus-visible {
  color: var(--ink);
  border-color: rgba(236,227,212,0.45);
  background: rgba(236,227,212,0.04);
}

/* ==========================================================================
   Ambient texture — grain + light leaks
   ========================================================================== */

.grain {
  position: fixed;
  inset: -10%;
  z-index: 500;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain-shift 8s steps(6) infinite;
}
@keyframes grain-shift {
  0%,100% { transform: translate(0,0); }
  20% { transform: translate(-1%,1%); }
  40% { transform: translate(1%,-1%); }
  60% { transform: translate(-1%,-1%); }
  80% { transform: translate(1%,1%); }
}

.light-leak {
  position: fixed;
  z-index: 0;
  pointer-events: none;
  width: 60vw;
  height: 60vw;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.16;
}
.light-leak--tl {
  top: -20vw; left: -20vw;
  background: radial-gradient(circle, var(--wine), transparent 70%);
}
.light-leak--br {
  bottom: -25vw; right: -20vw;
  background: radial-gradient(circle, var(--plum), transparent 70%);
  opacity: 0.14;
}

/* ==========================================================================
   Header
   ========================================================================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px clamp(20px, 5vw, 56px);
  background: linear-gradient(to bottom, rgba(11,10,8,0.92), rgba(11,10,8,0.5) 80%, transparent);
  backdrop-filter: blur(6px);
}

.mark {
  display: flex;
  align-items: center;
  gap: 10px;
}
.mark__img {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  filter: saturate(0.7) brightness(0.85);
  border: 1px solid rgba(236,227,212,0.25);
  flex-shrink: 0;
}
.mark__text {
  font-family: var(--sans);
  font-size: 12.5px;
  letter-spacing: 0.22em;
  font-weight: 500;
  color: var(--ink);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: clamp(18px, 3vw, 34px);
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.site-nav a { transition: color .3s var(--ease); }
.site-nav a:hover { color: var(--ink); }

.sound-toggle {
  background: none;
  border: 1px solid var(--line);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-dim);
  cursor: pointer;
  transition: color .3s var(--ease), border-color .3s var(--ease);
}
.sound-toggle:hover { color: var(--cyan); border-color: rgba(143,208,200,0.4); }
.sound-toggle svg { width: 13px; height: 13px; }
.icon-sound-off { display: none; }
.sound-toggle[aria-pressed="true"] .icon-sound-on { display: none; }
.sound-toggle[aria-pressed="true"] .icon-sound-off { display: block; }
.sound-toggle[aria-pressed="true"] { color: var(--cyan); border-color: rgba(143,208,200,0.5); }

/* ==========================================================================
   Hero
   ========================================================================== */

.hero {
  position: relative;
  min-height: 92vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding: 0 clamp(20px, 8vw, 96px);
  max-width: 1100px;
}

.hero__eyebrow {
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 28px;
  opacity: 0;
  animation: rise 1.1s var(--ease) 0.15s forwards;
}

.hero__title {
  font-family: var(--display);
  font-weight: 300;
  font-style: italic;
  font-size: clamp(2.1rem, 5vw, 3.6rem);
  line-height: 1.3;
  letter-spacing: 0.005em;
  color: var(--ink);
  margin: 0 0 30px;
  max-width: 900px;
  opacity: 0;
  animation: rise 1.3s var(--ease) 0.35s forwards;
}

.hero__note {
  font-family: var(--body);
  font-style: italic;
  font-size: 15px;
  color: var(--ink-faint);
  margin: 0 0 64px;
  opacity: 0;
  animation: rise 1.1s var(--ease) 0.6s forwards;
}

.hero__enter {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--sans);
  font-size: 11.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-dim);
  padding-bottom: 3px;
  border-bottom: 1px solid var(--line);
  opacity: 0;
  animation: rise 1.1s var(--ease) 0.85s forwards;
  transition: color .35s var(--ease), border-color .35s var(--ease);
}
.hero__enter:hover { color: var(--ink); border-color: var(--ink-dim); }
.hero__enter-arrow {
  display: inline-block;
  animation: bob 2.6s ease-in-out infinite;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes bob {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(4px); }
}

/* ==========================================================================
   Archive
   ========================================================================== */

.archive {
  position: relative;
  z-index: 1;
  padding: 6vw clamp(20px, 8vw, 96px) 10vw;
}

.archive__head {
  max-width: 620px;
  margin-bottom: clamp(40px, 6vw, 76px);
}
.archive__eyebrow {
  display: block;
  font-family: var(--sans);
  font-size: 11.5px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 16px;
}
.archive__title {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.9rem, 3.6vw, 2.8rem);
  margin: 0 0 16px;
  color: var(--ink);
}
.archive__sub {
  font-family: var(--body);
  font-style: italic;
  color: var(--ink-dim);
  font-size: 15.5px;
  margin: 0;
  max-width: 46ch;
}

.archive__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: clamp(14px, 2vw, 26px);
}
@media (max-width: 620px) {
  .archive__grid { grid-template-columns: 1fr; }
}

/* fragment card */
.frag {
  position: relative;
  aspect-ratio: 3 / 4.2;
  border-radius: 2px;
  overflow: hidden;
  cursor: pointer;
  isolation: isolate;
  opacity: 0;
  transform: translateY(24px);
  transition: transform .6s var(--ease), opacity .8s var(--ease);
}
.frag.is-visible { opacity: 1; transform: translateY(0); }

.frag__img {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  transform: scale(1.08);
  filter: saturate(0.9) brightness(0.72);
  transition: transform 1.1s var(--ease), filter .6s var(--ease);
}
.frag:hover .frag__img { transform: scale(1.14); filter: saturate(0.95) brightness(0.6); }

.frag__veil {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(6,5,4,0.92) 0%, rgba(6,5,4,0.35) 46%, rgba(6,5,4,0.15) 70%);
}

.frag__content {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 20px 18px;
}
.frag__index {
  display: block;
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.2em;
  color: rgba(236,227,212,0.5);
  margin-bottom: 10px;
}
.frag__title {
  font-family: var(--display);
  font-style: italic;
  font-weight: 400;
  font-size: 1.5rem;
  color: var(--ink);
  margin: 0 0 8px;
  line-height: 1.22;
}
.frag__line {
  font-family: var(--body);
  font-size: 12.5px;
  color: var(--ink-dim);
  line-height: 1.5;
  margin: 0;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height .5s var(--ease), opacity .4s var(--ease);
}
.frag:hover .frag__line,
.frag:focus-visible .frag__line { max-height: 4.5em; opacity: 1; }

.frag__date {
  position: absolute;
  top: 16px;
  right: 16px;
  font-family: var(--sans);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  color: rgba(236,227,212,0.45);
}

/* ==========================================================================
   About
   ========================================================================== */

.about {
  position: relative;
  z-index: 1;
  padding: 14vw clamp(20px, 8vw, 96px) 16vw;
  border-top: 1px solid var(--line);
}
.about__inner { max-width: 560px; }
.about__eyebrow {
  display: block;
  font-family: var(--sans);
  font-size: 11.5px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 26px;
}
.about__text {
  font-family: var(--display);
  font-style: italic;
  font-weight: 300;
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  line-height: 1.5;
  color: var(--ink);
  margin: 0 0 26px;
}
.about__muse {
  font-family: var(--body);
  color: var(--ink-dim);
  font-size: 15px;
  margin: 0 0 34px;
}
.about__link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--sans);
  font-size: 12.5px;
  letter-spacing: 0.1em;
  color: var(--ink-dim);
  border-bottom: 1px solid var(--line);
  padding-bottom: 3px;
  transition: color .3s var(--ease), border-color .3s var(--ease);
}
.about__link-icon {
  flex-shrink: 0;
  opacity: 0.85;
  transition: opacity .3s var(--ease);
}
.about__link:hover .about__link-icon { opacity: 1; }
.about__link:hover { color: var(--cyan); border-color: rgba(143,208,200,0.4); }

/* ==========================================================================
   Footer
   ========================================================================== */

.site-footer {
  position: relative;
  z-index: 1;
  padding: 26px clamp(20px, 8vw, 96px) 40px;
  display: flex;
  gap: 10px;
  font-family: var(--sans);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.site-footer__dot { opacity: 0.5; }

/* ==========================================================================
   Reading mode
   ========================================================================== */

.reader {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #060505;
  opacity: 0;
  visibility: hidden;
  transition: opacity .55s var(--ease);
  overflow: hidden;
}
.reader.is-open { opacity: 1; visibility: visible; }

.reader__bg {
  position: absolute;
  inset: -6%;
  background-size: cover;
  background-position: center;
  filter: saturate(0.7) brightness(0.28) blur(2px);
  transform: scale(1.05);
  transition: transform 12s linear, background-image .4s var(--ease);
}
.reader.is-open .reader__bg { transform: scale(1.14); }

.reader::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 40%, rgba(6,5,5,0.55), rgba(6,5,5,0.94) 75%);
}

.reader__grain {
  position: absolute;
  inset: -10%;
  opacity: 0.045;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain-shift 8s steps(6) infinite;
  z-index: 1;
}

.reader__close {
  position: absolute;
  top: clamp(16px,3vw,32px);
  right: clamp(16px,3vw,32px);
  z-index: 5;
  background: none;
  border: none;
  color: var(--ink-dim);
  cursor: pointer;
  padding: 10px;
  transition: color .3s var(--ease), transform .3s var(--ease);
}
.reader__close:hover { color: var(--ink); transform: rotate(90deg); }

.reader__scroll {
  position: relative;
  z-index: 2;
  height: 100%;
  overflow-y: auto;
  display: flex;
  justify-content: center;
}

.reader__content {
  max-width: 620px;
  width: 100%;
  padding: clamp(80px,14vh,140px) clamp(24px,6vw,10px) 100px;
  text-align: center;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity .8s var(--ease) .15s, transform .8s var(--ease) .15s;
}
.reader.is-open .reader__content { opacity: 1; transform: translateY(0); }

.reader__date {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 22px;
}
.reader__title {
  font-family: var(--display);
  font-style: italic;
  font-weight: 300;
  font-size: clamp(1.9rem, 4.4vw, 2.9rem);
  color: var(--ink);
  margin: 0 0 48px;
}
.reader__body {
  font-family: var(--body);
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  line-height: 2.05;
  color: rgba(236,227,212,0.92);
  white-space: pre-line;
}
.reader__body p { margin: 0 0 1.6em; }
.reader__body p:last-child { margin-bottom: 0; }

.reader__fragment {
  margin-top: 64px;
  font-family: var(--sans);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

body.reader-open { overflow: hidden; }

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

@media (max-width: 560px) {
  .site-header { padding: 16px 18px; }
  .mark__text { font-size: 11px; letter-spacing: 0.18em; }
  .site-nav { gap: 16px; font-size: 10.5px; }
  .hero { min-height: 88vh; padding: 0 20px; }
  .hero__title { max-width: 100%; }
  .frag__line { max-height: 4.5em; opacity: 1; } /* always show snippet on touch */
  .archive { padding-top: 14vw; }
  .about { padding-top: 20vw; padding-bottom: 22vw; }
}
