/* Kukai mode: the scrolling wall, its sort, the tiles with their season
   colour and hanko, the place of the one Linger (linger.css) and the report. */

/* scrolled tiles fade out before they reach the fixed chrome above and
   the corners below, instead of sliding under it */
.gwrap {
  height: 100%; overflow-y: auto; padding: 14vh 6vw max(12vh, 120px);
  --fade-from: 64px; --fade-top: 120px; --fade-bottom: 72px;
  /* a tile reached by keyboard scrolls clear of the fades, never under them */
  scroll-padding-block: var(--fade-top) var(--fade-bottom);
  -webkit-mask-image: linear-gradient(to bottom, transparent var(--fade-from), var(--ink-void) var(--fade-top), var(--ink-void) calc(100% - var(--fade-bottom)), transparent);
  mask-image: linear-gradient(to bottom, transparent var(--fade-from), var(--ink-void) var(--fade-top), var(--ink-void) calc(100% - var(--fade-bottom)), transparent);
}
.gwrap::-webkit-scrollbar { width: 0; }
.kukai-head { text-align: center; margin-bottom: 8vh; }
.kukai-head .gtitle { font-family: var(--font-label); font-weight: 300; font-size: var(--type-2); letter-spacing: var(--track-wide); text-transform: uppercase; color: var(--accent-quiet); }
.kukai-head .gsub { margin-top: 14px; font-style: italic; color: var(--paper-dim); font-size: 16px; }
/* the word behind Linger: a smaller, upright line, its Japanese in the glyph face */
.kukai-head .gsub-gloss { margin-top: 6px; font-size: 14px; color: var(--paper-faint); }
.gsub-gloss [lang="ja"] { letter-spacing: 0.08em; }
.gsub-gloss [lang="ja-Latn"] { font-style: italic; }

/* ---- subtle sort control ---- */
.gsort {
  margin-top: 22px; display: flex; flex-wrap: wrap; gap: 4px 14px;
  align-items: center; justify-content: center;
}
.gsort[hidden] { display: none; }
.gsort-label {
  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);
}
.gsort-opt {
  background: none; border: none; cursor: pointer;
  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);
  padding: 4px 2px;
  transition: color var(--dur-hover) var(--ease-breath);
}
.gsort-opt:hover { color: var(--paper); }
.gsort-opt.active { color: var(--accent); }
.grid {
  columns: 3 260px; column-gap: clamp(24px, 4vw, 56px); max-width: 1100px; margin: 0 auto;
}
.grid-empty { column-span: all; text-align: center; color: var(--paper-dim); font-style: italic; }
/* the tile's colour is its own season's accent: the tile carries
   data-season, so the season tokens apply to it; its Linger takes it too */
.tile {
  --tile-c: var(--accent); --linger-c: var(--tile-c);
  break-inside: avoid; margin-bottom: clamp(24px, 4vw, 56px);
  position: relative; overflow: hidden;
  isolation: isolate; /* own stacking context so the hanko can sit behind the verse */
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--tile-c) 7%, transparent), transparent 70%),
    var(--ink-deep);
  border: 1px solid var(--ink-soft);
  border-left: 2px solid color-mix(in srgb, var(--tile-c) 60%, var(--ink-soft));
  border-radius: 3px;
  padding: 38px 32px; cursor: pointer;
  opacity: 0; transform: translateY(14px);
  transition: opacity 0.8s var(--ease-breath), transform var(--dur-state) var(--ease-breath),
              border-color var(--dur-hover) var(--ease-breath), background var(--dur-hover) var(--ease-breath),
              box-shadow var(--dur-state) var(--ease-breath);
}
/* a season kanji bleeding off the top-right corner, faint as a hanko
   stamp pressed half off the paper */
.tile::after {
  content: var(--season-glyph);
  position: absolute; top: -18px; right: -12px; z-index: var(--z-behind);
  font-family: var(--font-glyph); font-size: 96px; line-height: 1;
  color: var(--tile-c); opacity: 0.07; pointer-events: none;
  transition: opacity var(--dur-state) var(--ease-breath);
}
.tile:hover::after { opacity: 0.12; }
.tile.in { opacity: 1; transform: none; }
.tile:hover {
  border-color: var(--tile-c);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--tile-c) 13%, transparent), transparent 72%),
    var(--ink-raised);
  box-shadow: var(--shadow-lift), 0 0 0 1px color-mix(in srgb, var(--tile-c) 14%, transparent);
}
/* the poem text is a real <button> (keyboard entry point of the tile);
   reset its chrome so it reads as verse, not a control */
.tile .tbody {
  display: block; width: 100%;
  background: none; border: none; padding: 0; margin: 0;
  color: inherit; font: inherit; text-align: inherit; cursor: pointer;
}
.tile .tbody:focus-visible { border-radius: 2px; }
/* verse in italic (identity.md 4); Japanese a visitor wrote stays upright, never slanted by the browser */
.tile .tline { display: block; font-style: italic; font-synthesis-style: none; font-size: 1.15rem; line-height: 1.85; color: var(--text); }
.tile .tfoot { margin-top: 22px; display: flex; justify-content: space-between; align-items: center; }
.tile .tauthor { font-style: italic; font-size: 14px; color: var(--paper-dim); }
.tile .tkept { color: var(--paper-faint); }
.tile .tseal {
  font-family: var(--font-glyph); font-size: 16px; color: var(--accent-quiet);
  transition: color var(--dur-hover) var(--ease-breath), text-shadow var(--dur-hover) var(--ease-breath);
}
.tile:hover .tseal { color: var(--tile-c); text-shadow: 0 0 14px color-mix(in srgb, var(--tile-c) 45%, transparent); }

/* the Linger at the tile's foot, its count across from it */
.tile .tlinger {
  margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--ink-soft);
  justify-content: space-between; gap: 4px 12px;
}

/* ---- report: a quiet word to the owner at the tile's foot; always there
   for touch and keyboard, lit when the tile is under the pointer ---- */
.treport {
  margin-top: 16px; display: flex; flex-wrap: wrap; align-items: baseline; justify-content: flex-end; gap: 4px 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);
}
.treport-btn {
  background: none; border: none; padding: 4px 2px; cursor: pointer; position: relative;
  font: inherit; letter-spacing: inherit; text-transform: inherit; color: var(--paper-faint);
  transition: color var(--dur-hover) var(--ease-breath);
}
/* invisible pad: a touch target wider than the small word */
.treport-btn::after { content: ""; position: absolute; inset: -8px -6px; }
.tile:hover .treport-btn, .treport-btn:focus-visible { color: var(--paper-dim); }
.treport-btn:hover { color: var(--tile-c); }
.treport-q { color: var(--paper-dim); }
/* a reported tile fades for this visitor before it leaves the grid */
.tile.gone { opacity: 0; pointer-events: none; }

/* phones: a single column under the two top rows */
@media (max-width: 640px) {
  .grid { columns: 1; }
  .gwrap { padding: 148px 7vw 64px; --fade-from: 100px; --fade-top: 140px; --fade-bottom: 40px; }
  .kukai-head { margin-bottom: 6vh; }
  .gsort { gap: 4px 10px; }
}

@media (max-height: 560px) {
  .gwrap { padding-top: 84px; padding-bottom: 48px; --fade-from: 64px; --fade-top: 80px; --fade-bottom: 32px; }
}

@media (max-height: 480px) and (max-width: 900px) {
  .gwrap { padding-top: 68px; --fade-from: 48px; --fade-top: 64px; }
}

/* a tile lifts under the pointer */
@media (prefers-reduced-motion: no-preference) {
  .tile.in:hover { transform: translateY(-2px); }
}

/* tiles appear in place, without rising or lifting */
@media (prefers-reduced-motion: reduce) {
  .tile, .tile.in { transform: none; transition: opacity 0.8s var(--ease-breath), border-color var(--dur-hover) var(--ease-breath), background var(--dur-hover) var(--ease-breath), box-shadow var(--dur-state) var(--ease-breath); }
}
