/* ==========================================================================
   TELiiK — base
   Sumi ink on washi. One accent, taken from the wax seal.
   Everything here is shared by all four pages.
   ========================================================================== */

:root {
  color-scheme: dark;

  /* ---- raw palette ----
     One accent, taken from the wax seal itself: sumi ink, washi, seal navy. */
  --washi: #FAF7F0;
  --sumi:  #1A1A1A;
  --seal:  #173F6D;

  /* ---- semantic: DARK is the site's default ----
     Not neutral black: the ground carries an indigo cast so the palette
     stays one family across both themes. The visitor's system setting is
     deliberately not consulted — only their own choice, stored below. */
  --bg:        #12141A;
  --bg-sunk:   #171A22;
  --fg:        #E9E5DC;
  --fg-muted:  #A19C92;
  --fg-faint:  #6F6B64;
  --rule:      rgba(233, 229, 220, 0.16);
  --rule-soft: rgba(233, 229, 220, 0.08);
  /* seal navy is far too dark on this ground: same hue, lifted to read */
  --accent:    #5C8DC9;
  --link:      #5C8DC9;
  --link-hover:#8FB4E0;

  /* ---- type ---- */
  --font-display: "Shippori Mincho B1", "Hiragino Mincho ProN", "Yu Mincho", "Songti SC", "Noto Serif SC", Georgia, serif;
  /* Songti/Noto Serif SC catch Simplified-only glyphs (及时行乐 in Landlord)
     that a Japanese mincho does not carry; Latin still resolves first. */
  --font-body:    "Shippori Mincho B1", "Hiragino Mincho ProN", "Songti SC", "Noto Serif SC", Georgia, serif;
  --font-mono:    "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* 1rem = 10px (html is 62.5%) */
  --t-xs:   clamp(1.05rem, 0.15vw + 1.0rem,  1.25rem);
  --t-sm:   clamp(1.25rem, 0.25vw + 1.2rem,  1.5rem);
  --t-base: clamp(1.6rem,  0.4vw  + 1.5rem,  1.9rem);
  --t-md:   clamp(1.9rem,  0.6vw  + 1.7rem,  2.4rem);
  --t-lg:   clamp(2.4rem,  1.2vw  + 2.0rem,  3.6rem);
  --t-xl:   clamp(3.2rem,  2.5vw  + 2.4rem,  5.6rem);
  --t-2xl:  clamp(4.4rem,  6vw    + 2.0rem, 10rem);
  --t-3xl:  clamp(5.2rem,  9vw    + 1.6rem, 15rem);

  /* ---- space ---- */
  --s-1: 0.8rem;
  --s-2: 1.6rem;
  --s-3: 2.4rem;
  --s-4: 3.2rem;
  --s-5: 4.8rem;
  --s-6: 6.4rem;
  --s-7: 9.6rem;
  --s-8: 14rem;
  --s-9: 20rem;

  /* ma — the page's breathing room, deliberately large */
  --gutter: clamp(2.4rem, 7vw, 16rem);
  --measure: 62ch;

  --nav-h: 7.2rem;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* ---- semantic: light, only when the visitor asks for it ---- */
:root[data-theme="light"] {
  color-scheme: light;
  --bg:        var(--washi);
  --bg-sunk:   #F2EEE5;
  --fg:        var(--sumi);
  --fg-muted:  #6B665D;
  --fg-faint:  #9C978D;
  --rule:      rgba(26, 26, 26, 0.14);
  --rule-soft: rgba(26, 26, 26, 0.07);
  --accent:    var(--seal);
  --link:      var(--seal);
  --link-hover:#0E2A4A;
}

/* ==========================================================================
   reset
   ========================================================================== */

*,
*::before,
*::after { margin: 0; padding: 0; box-sizing: border-box; }

html {
  font-size: 62.5%;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--t-base);
  line-height: 1.75;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.4s var(--ease), color 0.4s var(--ease);
}

main { flex: 1 0 auto; }

/* height:auto matters — without it an <img> carrying width/height attributes
   keeps its attribute height while max-width shrinks the width, and the
   picture stretches. */
img { max-width: 100%; height: auto; display: block; }
li  { list-style: none; }

a {
  color: var(--link);
  text-decoration: none;
  transition: color 0.25s var(--ease);
}
a:hover { color: var(--link-hover); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 1px;
}

::selection { background: var(--accent); color: var(--washi); }

/* ==========================================================================
   primitives
   ========================================================================== */

/* The wax seal, used only where it is large enough to actually read.
   There is no small stand-in: at text size, state is carried by colour. */
.seal {
  display: inline-block;
  width: 4.4rem;
  height: 4.4rem;
  flex: none;
  background: url("../images/teliikseal.png") center / contain no-repeat;
}
.seal--lg { width: 6rem; height: 6rem; }

/* the wax is dark navy and sinks into the dark ground without a lift; on the
   light ground it needs none, so light undoes it rather than dark adding it */
.seal { filter: brightness(1.8) saturate(1.05); }
:root[data-theme="light"] .seal { filter: none; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  font-weight: 400;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--fg-faint);
  line-height: 1.4;
}

.rule {
  height: 1px;
  background: var(--rule);
  border: 0;
  width: 100%;
}

.wrap {
  padding-inline: var(--gutter);
  width: 100%;
  max-width: 152rem;
  margin-inline: auto;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* section + its head: shared by home, music and inspiration */
.section { padding-block: clamp(6rem, 12vh, 14rem); }

/* stacked on a phone, that rhythm reads as dead air — tighten it.
   The masthead and footer are trimmed at the foot of this file, after
   their own rules, or those would win on source order. */
@media (max-width: 700px) {
  .section { padding-block: clamp(3.2rem, 5vh, 5rem); }
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3);
  padding-bottom: var(--s-3);
  border-bottom: 1px solid var(--rule);
}

.section-head h2 {
  font-family: var(--font-display);
  font-size: var(--t-lg);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1;
}

.prose {
  max-width: var(--measure);
  font-size: var(--t-base);
  line-height: 1.85;
  color: var(--fg-muted);
}
.prose p + p { margin-top: 1.4em; }

/* tategaki spine — page name set vertically down the left margin.
   Decorative echo of the nav, so it stays out of the a11y tree. */
.spine {
  position: fixed;
  left: clamp(1.6rem, 2.4vw, 3.6rem);
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-3);
  pointer-events: none;
  writing-mode: vertical-rl;
  text-orientation: mixed;
}

.spine::before {
  content: "";
  width: 1px;
  height: 5.6rem;
  background: var(--accent);
  flex: none;
}

.spine span {
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: var(--fg-faint);
}

@media (max-width: 1180px) {
  .spine { display: none; }
}

/* ==========================================================================
   masthead — every page opens the same way, offset left, mostly empty
   ========================================================================== */

.masthead {
  padding-top: calc(var(--nav-h) + clamp(6rem, 14vh, 18rem));
  padding-bottom: clamp(6rem, 12vh, 16rem);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--s-3);
}

/* Matched to .hero-name on the home page so every page title is one size.
   Tracking stays tight here — 0.12em suits the TELiiK wordmark but pulls a
   real word like "Inspiration" apart. */
.masthead h1 {
  font-family: var(--font-display);
  font-size: clamp(3.6rem, 5vw + 1.6rem, 8.4rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.01em;
}

/* shrink-to-fit around the title, so the rule below stops where the word does */
.masthead-title {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--s-2);
}

/* the same bookend that closes a poem, closing the page title */
.masthead-end {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  width: 100%;
}
.masthead-end::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--rule);
}

.masthead .prose { margin-top: var(--s-2); }

/* ==========================================================================
   nav
   ========================================================================== */

.nav {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--nav-h);
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding-inline: var(--gutter);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(14px) saturate(1.1);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
  border-bottom: 1px solid var(--rule-soft);
  transition: transform 0.45s var(--ease), background-color 0.4s var(--ease);
}

.nav[data-hidden="true"] { transform: translateY(-100%); }

.nav-mark {
  font-family: var(--font-display);
  font-size: var(--t-md);
  font-weight: 700;
  letter-spacing: 0.22em;
  color: var(--fg);
  display: inline-flex;
  align-items: center;
  gap: 0.9rem;
}
.nav-mark:hover,
.nav-mark:focus-visible { color: var(--accent); }

.nav-right {
  display: flex;
  align-items: center;
  gap: clamp(2rem, 3vw, 4rem);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: clamp(2rem, 3vw, 4.4rem);
}

.nav-links a {
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--fg-muted);
  position: relative;
  padding-block: 0.6rem;
}

.nav-links a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 0;
  height: 1px;
  background: var(--accent);
  transition: width 0.3s var(--ease);
}

.nav-links a:hover,
.nav-links a[aria-current="page"] { color: var(--fg); }
.nav-links a:hover::after,
.nav-links a[aria-current="page"]::after { width: 100%; }

/* Theme toggle — a half-filled disc, labelled with the theme it switches TO
   so a visitor doesn't have to guess. The label is set in the nav's own type. */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.6rem 0;
  background: none;
  border: 0;
  cursor: pointer;
  color: var(--fg-muted);
  transition: color 0.25s var(--ease);
}
.theme-toggle:hover,
.theme-toggle:focus-visible { color: var(--fg); }

.theme-dot {
  width: 1.5rem;
  height: 1.5rem;
  flex: none;
  border-radius: 50%;
  border: 1px solid currentColor;
  background: linear-gradient(90deg, currentColor 0 50%, transparent 50% 100%);
  transition: transform 0.5s var(--ease);
}
.theme-toggle:hover .theme-dot { transform: rotate(180deg); }
:root[data-theme="dark"] .theme-toggle .theme-dot { transform: rotate(180deg); }
:root[data-theme="dark"] .theme-toggle:hover .theme-dot { transform: rotate(0deg); }

.theme-word {
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

/* Which word shows is decided in CSS, not JS, so it is already correct on the
   first paint — the script is deferred and would flash the wrong word.
   Dark is the default, so "Light" is what the toggle offers by default. */
.theme-word--dark { display: none; }
.theme-word--light { display: inline; }
:root[data-theme="light"] .theme-word--dark { display: inline; }
:root[data-theme="light"] .theme-word--light { display: none; }

/* hamburger */
.nav-burger {
  display: none;
  width: 3.4rem;
  height: 3.4rem;
  background: none;
  border: 0;
  cursor: pointer;
  position: relative;
  color: var(--fg);
}
.nav-burger i {
  position: absolute;
  left: 0.7rem;
  width: 2rem;
  height: 1px;
  background: currentColor;
  transition: transform 0.35s var(--ease), opacity 0.2s var(--ease);
}
.nav-burger i:nth-child(1) { top: 1.3rem; }
.nav-burger i:nth-child(2) { top: 2rem; }
.nav-burger[aria-expanded="true"] i:nth-child(1) { transform: translateY(0.35rem) rotate(45deg); }
.nav-burger[aria-expanded="true"] i:nth-child(2) { transform: translateY(-0.35rem) rotate(-45deg); }

@media (max-width: 820px) {
  .nav-burger { display: block; }

  /* the word would crowd the burger; the disc alone carries it here */
  .theme-words { display: none; }

  .nav-links {
    position: fixed;
    inset: var(--nav-h) 0 auto 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    padding: var(--s-3) var(--gutter) var(--s-5);
    background: var(--bg);
    border-bottom: 1px solid var(--rule);
    clip-path: inset(0 0 100% 0);
    transition: clip-path 0.45s var(--ease);
  }
  .nav-links[data-open="true"] { clip-path: inset(0 0 0 0); }

  .nav-links a {
    font-size: var(--t-sm);
    padding-block: var(--s-2);
    width: 100%;
    border-bottom: 1px solid var(--rule-soft);
  }
}

/* ==========================================================================
   footer
   ========================================================================== */

/* Three columns with equal 1fr flanks, so the seal is exactly centred no
   matter how wide the wordmark or the copyright line get — space-between
   would only centre it by accident. Vertical padding is symmetric for the
   same reason. */
.footer {
  position: relative;
  margin-top: clamp(8rem, 16vh, 20rem);
  padding: var(--s-6) var(--gutter);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--s-4);
}

/* The rule is drawn rather than set as border-top: a 1px border lives inside
   the box and pushes the padding box down by that pixel, so the seal would
   sit 1px below true centre. */
.footer::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--rule);
}

.footer-mark {
  font-family: var(--font-display);
  font-size: var(--t-md);
  font-weight: 700;
  letter-spacing: 0.22em;
  color: var(--fg);
  background: none;
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0;
}
.footer-mark:hover { color: var(--accent); }

/* the largest the seal appears anywhere — bigger than .seal--lg's 6rem */
.footer-seal {
  width: clamp(7.5rem, 9vw, 11rem);
  height: clamp(7.5rem, 9vw, 11rem);
  justify-self: center;
}

.footer-meta {
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg-faint);
  justify-self: end;
  text-align: right;
}

/* ==========================================================================
   showcase — a single work held in a crop-marked window. Used by the home
   page hero and by the release feature on music.html.
   ========================================================================== */

.showcase {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding: clamp(2rem, 2.4vw, 3.2rem);
  color: var(--fg);
  width: 100%;
}

/* printer's crop marks: the window's edges are implied, not drawn */
.showcase::before,
.showcase::after,
.showcase-marks::before,
.showcase-marks::after {
  content: "";
  position: absolute;
  width: 1.8rem;
  height: 1.8rem;
  border-style: solid;
  border-color: var(--rule);
  pointer-events: none;
  transition: border-color 0.45s var(--ease), width 0.45s var(--ease),
              height 0.45s var(--ease);
}

.showcase::before { top: 0; left: 0; border-width: 1px 0 0 1px; }
.showcase::after { bottom: 0; right: 0; border-width: 0 1px 1px 0; }

.showcase-marks { position: absolute; inset: 0; pointer-events: none; }
.showcase-marks::before { top: 0; right: 0; border-width: 1px 1px 0 0; }
.showcase-marks::after { bottom: 0; left: 0; border-width: 0 0 1px 1px; }

.showcase:hover::before,
.showcase:hover::after,
.showcase:hover .showcase-marks::before,
.showcase:hover .showcase-marks::after,
.showcase:focus-visible::before,
.showcase:focus-visible::after,
.showcase:focus-visible .showcase-marks::before,
.showcase:focus-visible .showcase-marks::after {
  border-color: var(--accent);
  width: 2.8rem;
  height: 2.8rem;
}

.showcase-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-2);
  padding-bottom: var(--s-1);
  border-bottom: 1px solid var(--rule-soft);
}
.showcase-head .label { color: var(--fg); letter-spacing: 0.32em; }

.showcase-media {
  overflow: hidden;
  border-radius: 2px;
  background: var(--bg-sunk);
  aspect-ratio: 3 / 2;
  margin-block: var(--s-1);
}
.showcase-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.9s var(--ease);
}
.showcase:hover .showcase-media img,
.showcase:focus-visible .showcase-media img { transform: scale(1.04); }

.showcase-title {
  font-family: var(--font-display);
  font-size: var(--t-lg);
  font-weight: 700;
  line-height: 1.06;
  letter-spacing: -0.015em;
}
.showcase:hover .showcase-title { color: var(--accent); }

.showcase-blurb {
  font-size: var(--t-sm);
  line-height: 1.75;
  color: var(--fg-muted);
  max-width: 46ch;
}

.showcase-cta {
  margin-top: var(--s-1);
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--link);
}
.showcase-cta .seal { width: 3.2rem; height: 3.2rem; }
.showcase-cta .arrow { transition: transform 0.35s var(--ease); }
.showcase:hover .showcase-cta { color: var(--accent); }
.showcase:hover .showcase-cta .arrow { transform: translateX(0.5rem); }

/* ==========================================================================
   motion — one gesture, used everywhere: rise and settle
   ========================================================================== */

.reveal {
  opacity: 0;
  transform: translateY(2.4rem);
  transition: opacity 0.9s var(--ease), transform 0.9s var(--ease);
}
.reveal.is-visible { opacity: 1; transform: none; }

/* rules draw themselves in */
.draw {
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 1.1s var(--ease);
}
.draw.is-visible { transform: scaleX(1); }

/* ==========================================================================
   phone spacing — must sit after .masthead and .footer to win on source order
   ========================================================================== */

@media (max-width: 700px) {
  .masthead {
    padding-top: calc(var(--nav-h) + clamp(3rem, 6vh, 6rem));
    padding-bottom: clamp(3rem, 5vh, 5rem);
  }

  /* stacked and centred; padding stays symmetric so the seal is still
     exactly on the footer's vertical centre line */
  .footer {
    margin-top: clamp(4rem, 7vh, 8rem);
    padding-block: var(--s-4);
    grid-template-columns: 1fr;
    justify-items: center;
    gap: var(--s-3);
  }
  .footer-mark,
  .footer-meta { justify-self: center; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .reveal { opacity: 1; transform: none; }
  .draw { transform: scaleX(1); }
}
