/* Gallery mode: the scrolling wall, its tabs and sort, the tiles with their
   season colour and hanko, and the quiet vote marks. */

/* 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; }
.gallery-head { text-align: center; margin-bottom: 8vh; }
.gallery-head .gtitle { font-family: var(--font-label); font-weight: 300; font-size: var(--type-2); letter-spacing: 0.46em; text-transform: uppercase; color: var(--accent-quiet); }
.gallery-head .gsub { margin-top: 14px; font-style: italic; color: var(--paper-dim); font-size: 16px; }

/* ---- collection tabs (masters / other hands) ---- */
.gtabs {
  display: inline-flex; gap: 6px; margin-bottom: 26px;
  border: 1px solid var(--ink-soft); border-radius: 40px; padding: 4px;
}
.gtab {
  background: none; border: none; cursor: pointer;
  font-family: var(--font-label); font-weight: 300; font-size: var(--type-1);
  letter-spacing: 0.28em; text-transform: uppercase; color: var(--paper-dim);
  padding: 9px 20px; border-radius: 40px;
  transition: color var(--dur-hover) var(--ease-breath), background var(--dur-hover) var(--ease-breath);
}
.gtab:hover { color: var(--paper); }
.gtab.active { color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }

/* ---- subtle sort control (community only) ---- */
.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: 300; font-size: var(--type-1);
  letter-spacing: 0.3em; text-transform: uppercase; color: var(--paper-faint);
}
.gsort-opt {
  background: none; border: none; cursor: pointer;
  font-family: var(--font-label); font-weight: 300; font-size: var(--type-1);
  letter-spacing: 0.2em; 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 */
.tile {
  --tile-c: var(--accent);
  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; }
.tile .tline { display: block; 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); }
.tile .tsource { margin-top: 12px; font-family: var(--font-label); font-weight: 300; font-size: var(--type-1); letter-spacing: 0.1em; line-height: 1.7; color: var(--paper-faint); font-style: italic; }

/* ---- voting: contemplative appreciation, not a leaderboard ---- */
.tvotes {
  margin-top: 22px; padding-top: 18px;
  border-top: 1px solid var(--ink-soft);
  display: flex; flex-direction: column; gap: 11px;
}
/* small cue that the marks below are an input, not a read-only score */
.tvote-head {
  font-family: var(--font-label); font-weight: 400; font-size: var(--type-1);
  letter-spacing: 0.34em; text-transform: uppercase; color: var(--accent-quiet);
  margin-bottom: 3px;
}
.tdim { display: flex; align-items: center; gap: 6px 12px; }
.tdim-name {
  flex: 1; font-family: var(--font-label); font-weight: 300; font-size: var(--type-1);
  letter-spacing: 0.22em; text-transform: uppercase; color: var(--paper-dim);
}
.tdim-marks { display: flex; gap: 7px; }
.tmark {
  width: 13px; height: 13px; border-radius: 50%;
  background: none; border: 1.5px solid var(--paper-dim); padding: 0; cursor: pointer;
  position: relative;
  transition: background 0.45s var(--ease-breath), border-color 0.45s var(--ease-breath), transform 0.45s var(--ease-breath);
}
/* invisible pad: ~25px effective touch target on a 13px mark */
.tmark::after { content: ""; position: absolute; inset: -6px; border-radius: 50%; }
.tmark:focus-visible { border-color: var(--tile-c); }
/* avg fill (faint), tinted to the poem's season */
.tmark.avg { background: color-mix(in srgb, var(--tile-c) 50%, transparent); border-color: color-mix(in srgb, var(--tile-c) 50%, transparent); }
/* this browser's own vote (solid season colour) takes precedence */
.tmark.mine { background: var(--tile-c); border-color: var(--tile-c); }
/* star-rating hover preview: hovering a row fills every mark, then the marks
   after the hovered one empty again, so you see exactly what you'd give */
.tdim-marks:hover .tmark {
  transform: scale(1.15);
  border-color: var(--tile-c);
  background: color-mix(in srgb, var(--tile-c) 60%, transparent);
}
.tdim-marks:hover .tmark:hover ~ .tmark {
  transform: none;
  border-color: var(--paper-dim);
  background: none;
}
.tdim-num {
  min-width: 30px; text-align: right;
  font-family: var(--font-label); font-weight: 300; font-size: var(--type-1);
  letter-spacing: 0.04em; color: var(--paper-faint); font-variant-numeric: tabular-nums;
}
.tvote-foot {
  margin-top: 4px; display: flex; justify-content: space-between; align-items: baseline;
  font-family: var(--font-label); font-weight: 300; font-size: var(--type-1);
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--paper-faint);
}
.tvote-foot .toverall { color: var(--tile-c); }

/* 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; }
  .gallery-head { margin-bottom: 6vh; }
  .gtab { padding: 8px 14px; letter-spacing: 0.2em; }
  .gsort { gap: 4px 10px; }
}

/* very small phones: the two tabs keep one line each, and each vote's
   marks sit under its name rather than past the tile's edge */
@media (max-width: 380px) {
  .gtab { padding: 8px 10px; letter-spacing: 0.12em; }
  .tdim { flex-wrap: wrap; }
  .tdim-name { flex-basis: 100%; }
}

@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; a freshly chosen mark settles with one
   small breath */
@media (prefers-reduced-motion: no-preference) {
  .tile.in:hover { transform: translateY(-2px); }
  .tmark.just-set { animation: markSettle 0.7s var(--ease-breath); }
  @keyframes markSettle {
    0%   { transform: scale(0.7); }
    55%  { transform: scale(1.25); }
    100% { transform: scale(1); }
  }
}

/* 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); }
}
