/* The masters: the archive (/masters), with its hero, the find field
   archive.js shows, the folded newest poems and index of poets, one
   section per season folding in a <details>, each poem with its reading,
   original and source, and the closing call; and each poem's own page
   (/masters/<slug>), the same poem alone, larger, with its neighbours. */

/* the gutter sits outside the measure: vw padding inside a ch max-width
   would shrink the text column as the screen widens */
.archive { position: relative; z-index: var(--z-panel); width: min(64ch, 100% - 14vw); margin: 0 auto; padding-block: 24vh 18vh; }

.archive-hero { text-align: center; margin-bottom: 14vh; }
.archive-hero .glyph-big {
  display: block; font-family: var(--font-glyph);
  font-size: clamp(3rem, 9vw, 5rem); color: var(--accent); margin-bottom: 26px; line-height: 1;
}
.archive-hero .eyebrow {
  font-family: var(--font-label); font-weight: 400; font-size: var(--type-1);
  text-transform: uppercase; letter-spacing: var(--track-wide); color: var(--accent-quiet); margin-bottom: 30px;
}
.archive-hero h1 {
  font-family: var(--font-verse); font-weight: 400; font-size: clamp(1.9rem, 5vw, 2.9rem);
  line-height: 1.45; color: var(--text); letter-spacing: 0.02em; max-width: 24ch; margin: 0 auto;
}
.archive-hero .lede {
  margin-top: 38px; font-style: italic; font-size: 1.12rem; line-height: 1.85;
  color: var(--paper-dim); max-width: 46ch; margin-left: auto; margin-right: auto;
}
.lede-link { color: var(--accent); text-decoration: none; border-bottom: 1px solid var(--ink-soft); }

/* the find: a field with a lit underline, and under it the count it speaks */
.archive-find { margin: 0 0 8vh; }
.af-label {
  display: block; margin-bottom: 12px; font-family: var(--font-label); font-weight: 400; font-size: var(--type-1);
  text-transform: uppercase; letter-spacing: var(--track-label); color: var(--paper-faint);
}
.af-input {
  width: 100%; appearance: none; background: none; border: none; border-bottom: 1px solid var(--ink-soft); border-radius: 0;
  color: var(--text); font-family: var(--font-verse); font-size: 1.2rem; line-height: 1.7; padding: 8px 0;
}
.af-input::placeholder { color: var(--paper-faint); font-style: italic; }
/* the browser's own clear mark is out of the palette; Escape clears, as does emptying the field */
.af-input::-webkit-search-cancel-button { appearance: none; }
.af-input:hover { border-color: var(--paper-faint); }
.af-input:focus { border-color: var(--accent); }
/* the lit underline is the field's focus; the transparent outline still shows in forced-colors modes */
.af-input:focus-visible { outline-color: transparent; }
.af-status { min-height: 1.6em; margin: 14px 0 0; font-family: var(--font-verse); font-style: italic; font-size: 1rem; line-height: 1.6; color: var(--paper-dim); }

.archive-season, .archive-new, .archive-poets { margin-bottom: 8vh; }
/* each poet, or each season of the newest poems, with its count, then the first line of each poem;
   two columns where the measure allows */
.ap-list, .an-list { list-style: none; margin: 0; padding: 0; columns: 2 24ch; column-gap: 48px; }
.ap-poet, .an-season { break-inside: avoid; margin: 0 0 5vh; }
.ap-name, .an-name { display: inline; margin: 0; font-family: var(--font-verse); font-weight: 400; font-size: 1.2rem; color: var(--text); }
.ap-count, .an-count {
  margin-left: 12px; white-space: nowrap; font-family: var(--font-label); font-weight: 400; font-size: var(--type-1);
  letter-spacing: var(--track-label); text-transform: uppercase; color: var(--paper-faint);
}
.ap-poems, .an-poems { list-style: none; margin: 12px 0 0; padding: 0 0 0 18px; border-left: 1px solid color-mix(in srgb, var(--accent) 24%, var(--ink-soft)); }
.ap-poems a, .an-poems a {
  display: inline-block; padding: 4px 0; text-decoration: none; font-family: var(--font-verse); font-style: italic;
  font-size: 1.05rem; line-height: 1.6; color: var(--paper-dim);
}
.ap-poems a:hover, .ap-poems a:focus-visible,
.an-poems a:hover, .an-poems a:focus-visible { color: var(--accent); }
/* the way into Ma for a season: above its fold so it shows while closed, at the foot of a poem's page */
.as-read, .pp-read {
  text-decoration: none; font-family: var(--font-label); font-weight: 400; font-size: var(--type-1);
  letter-spacing: var(--track-label); text-transform: uppercase; color: var(--accent-quiet);
}
.as-read { display: block; width: fit-content; margin: 0 0 6px auto; padding: 12px 0 12px var(--track-label); }
.pp-read { display: inline-block; padding: 12px 0 12px var(--track-label); }
.as-read:hover, .as-read:focus-visible, .pp-read:hover, .pp-read:focus-visible { color: var(--accent); }
/* the summary is the season's header; a quiet chevron stands for the native marker */
.as-head { display: flex; align-items: baseline; gap: 18px; cursor: pointer; list-style: none;
  padding-bottom: 22px; border-bottom: 1px solid color-mix(in srgb, var(--accent) 16%, var(--ink-soft)); }
.as-head::-webkit-details-marker { display: none; }
.as-head::after {
  content: ''; flex: none; align-self: center; width: 7px; height: 7px; margin-right: 4px;
  border-right: 1px solid var(--paper-faint); border-bottom: 1px solid var(--paper-faint);
  transform: translateY(-3px) rotate(45deg);
}
.as-head:hover::after { border-color: var(--accent); }
.as-fold[open] > .as-head { margin-bottom: 6vh; }
.as-fold[open] > .as-head::after { transform: translateY(2px) rotate(-135deg); }
.as-glyph { font-family: var(--font-glyph); font-size: 2.4rem; color: var(--accent-quiet); line-height: 1; }
.as-head h2 { font-family: var(--font-verse); font-weight: 400; font-size: clamp(1.5rem, 4vw, 2rem); color: var(--text); margin: 0; }
.as-head .as-word {
  font-family: var(--font-label); font-weight: 400; font-size: var(--type-1); text-transform: uppercase;
  letter-spacing: var(--track-label); color: var(--paper-faint); margin-left: 10px; white-space: nowrap;
}
.as-head .as-word [lang="ja"] { font-size: 1.3em; line-height: 1; letter-spacing: 0.16em; }
.as-count {
  margin-left: auto; white-space: nowrap; font-family: var(--font-label); font-weight: 400; font-size: var(--type-1);
  letter-spacing: var(--track-label); text-transform: uppercase; color: var(--paper-faint);
}

/* each section re-scopes --accent via its data-season, so the hairline
   carries the poem's season, the same cue as the Kukai tiles */
.archive-poem { position: relative; margin: 0 0 7vh; padding-left: 26px; border-left: 1px solid color-mix(in srgb, var(--accent) 24%, var(--ink-soft)); }
.al-en { margin: 0; }
.al-en .al-line {
  display: block; font-family: var(--font-verse); font-style: italic; font-size: 1.3rem;
  line-height: 1.9; color: var(--text); letter-spacing: 0.02em;
}
.al-by {
  margin: 16px 0 0; font-family: var(--font-label); font-weight: 400; font-size: var(--type-1);
  letter-spacing: var(--track-label); text-transform: uppercase; color: var(--accent-quiet);
}
.al-jp { margin: 20px 0 0; font-family: var(--font-glyph); font-size: 1.15rem; color: var(--paper-dim); letter-spacing: 0.06em; }
.al-romaji { margin: 8px 0 0; font-family: var(--font-verse); font-style: italic; font-size: 1rem; color: var(--paper-faint); }
.al-source { margin: 14px 0 0; font-family: var(--font-label); font-weight: 400; font-size: var(--type-1); letter-spacing: var(--track-quiet); line-height: 1.7; color: var(--paper-faint); }
.archive-poem:target { border-left-color: var(--accent); }
/* a poem's first line is the way to its own page, underlined at rest in the season's quiet
   accent; the poet's name, on that page, the way back to the index */
.al-to, .al-by a {
  color: inherit; text-decoration: underline 1px var(--ink-soft); text-underline-offset: 0.3em;
}
.al-to { text-decoration-color: var(--accent-quiet); }
.al-to:hover, .al-to:focus-visible, .al-by a:hover, .al-by a:focus-visible { color: var(--accent); text-decoration-color: var(--accent-quiet); }

.archive-close { text-align: center; margin-top: 14vh; padding-top: 12vh; border-top: 1px solid var(--ink-soft); }
.archive-close .glyph-seal, .pp-close .glyph-seal { display: block; font-family: var(--font-glyph); font-size: 1.6rem; color: var(--accent-quiet); }
.archive-close .glyph-seal { margin-bottom: 36px; }
.archive-close .close-line { font-family: var(--font-verse); font-style: italic; font-size: 1.3rem; line-height: 1.8; color: var(--paper-dim); max-width: 38ch; margin: 0 auto 44px; }

/* a poem's own page: the poem alone in its season's light, larger, with room around it */
.poem-page { position: relative; z-index: var(--z-panel); width: min(42rem, 100% - 14vw); margin: 0 auto; padding-block: 26vh 16vh; }
.pp-season { display: flex; align-items: center; gap: 18px; margin-bottom: 9vh; }
.pp-glyph { font-family: var(--font-glyph); font-size: 2.4rem; line-height: 1; color: var(--accent-quiet); }
.pp-word {
  margin: 0; font-family: var(--font-label); font-weight: 400; font-size: var(--type-1);
  letter-spacing: var(--track-label); text-transform: uppercase; color: var(--paper-faint);
}
.pp-word [lang="ja"] { font-size: 1.3em; line-height: 1; letter-spacing: 0.16em; }
.pp-en { font-weight: 400; font-size: inherit; }
.pp-en .al-line { font-size: clamp(1.5rem, 4vw, 2.1rem); line-height: 1.75; }
.poem-page .al-by { margin-top: 30px; }
.poem-page .al-jp { margin-top: 8vh; font-size: 1.45rem; line-height: 1.8; }
.poem-page .al-romaji { margin-top: 10px; font-size: 1.1rem; }
.poem-page .al-source { margin-top: 24px; max-width: 46ch; }
/* the poems either side in the season, the next always on the right */
.pp-near { display: grid; grid-template-columns: 1fr 1fr; column-gap: 40px; margin-top: 16vh; padding-top: 6vh; border-top: 1px solid var(--ink-soft); }
.pp-near a { display: block; padding: 6px 0; text-decoration: none; }
.pp-next { grid-column: 2; text-align: right; }
.pp-dir {
  display: block; margin-bottom: 10px; font-family: var(--font-label); font-weight: 400; font-size: var(--type-1);
  letter-spacing: var(--track-label); text-transform: uppercase; color: var(--paper-faint);
}
.pp-name { font-family: var(--font-verse); font-style: italic; font-size: 1.1rem; line-height: 1.6; color: var(--paper-dim); }
.pp-near a:hover .pp-name, .pp-near a:focus-visible .pp-name { color: var(--accent); }
.pp-close { margin-top: 14vh; text-align: center; }
.pp-close .glyph-seal { margin-bottom: 28px; }

@media (max-width: 640px) {
  .archive { width: min(64ch, 100% - 16vw); padding-block: 18vh 14vh; }
  /* the header stacks beside its kanji: name, then season word, then count; the chevron stays on the name's row */
  .as-head { display: grid; grid-template-columns: auto 1fr auto; column-gap: 14px; }
  .as-glyph { grid-row: 1 / span 2; align-self: start; }
  .as-head h2 { grid-column: 2; grid-row: 1; }
  .as-head .as-word { display: block; margin: 8px 0 0; }
  .as-count { grid-column: 2; grid-row: 2; margin: 6px 0 0; }
  .as-head::after { grid-column: 3; grid-row: 1; }
  .archive-poem { padding-left: 18px; }
  /* a linked poem or season lands clear of the fixed 間 */
  .archive-season, .archive-new, .archive-poem, .ap-poet { scroll-margin-top: 80px; }
  .poem-page { width: min(42rem, 100% - 16vw); padding-block: 20vh 12vh; }
  .pp-season { margin-bottom: 7vh; }
  /* one column: the previous above the next, both from the left */
  .pp-near { grid-template-columns: 1fr; row-gap: 4vh; margin-top: 12vh; }
  .pp-next { grid-column: 1; text-align: left; }
}

@media (prefers-reduced-motion: no-preference) {
  .af-input { transition: border-color var(--dur-state) var(--ease-breath); }
  .ap-poems a, .an-poems a, .pp-name { transition: color var(--dur-hover) var(--ease-breath); }
  .as-read, .pp-read { transition: color var(--dur-state) var(--ease-breath); }
  .al-to, .al-by a { transition: color var(--dur-hover) var(--ease-breath), text-decoration-color var(--dur-hover) var(--ease-breath); }
  .as-head::after { transition: transform var(--dur-state) var(--ease-breath), border-color var(--dur-hover) var(--ease-breath); }
  /* where the browser styles a fold's content, it breathes in and out; elsewhere it simply shows */
  .as-fold::details-content {
    opacity: 0;
    transition: opacity var(--dur-state) var(--ease-breath), content-visibility var(--dur-state) allow-discrete;
  }
  .as-fold[open]::details-content { opacity: 1; }
}
