/* (R)Evolution landing. Tokens, type and chrome live in base.css. */

:root {
  --bitmap-w: min(58vw, calc(82svh * 1.2));
}

/* ---------- front: the R has turned away ---------- */

.face {
  display: grid;
  padding: 0 var(--pad);
  column-gap: clamp(16px, 2.5vw, 40px);
}

.face--front {
  grid-template-columns: var(--bitmap-w) 1fr auto;
  grid-template-areas: "title statement spine";
  align-items: end;
  padding-top: clamp(8px, 2vw, 24px);
}

.title { display: contents; margin: 0; }

.bitmap { display: block; }
.bitmap svg { width: 100%; height: auto; }

.face--front .bitmap { grid-area: title; width: var(--bitmap-w); }

.fallback {
  font-variation-settings: "wdth" 50;
  font-weight: 900;
  font-size: 40vw;
  line-height: 0.8;
}

/* "EVOLUTION" stands on its end, reading up the edge of the page. */
.spine {
  grid-area: spine;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-variation-settings: "wdth" 50;
  font-weight: 900;
  font-size: calc(var(--bitmap-w) / 1.2 / 3.75);
  line-height: 0.74;
  letter-spacing: -0.01em;
  align-self: end;
  user-select: none;
}

.statement {
  grid-area: statement;
  margin: 0 0 0.2em;
  max-width: 17ch;
  font-variation-settings: "wdth" 150;
  font-weight: 330;
  font-size: clamp(1.25rem, 2.1vw, 2rem);
  line-height: 1.12;
  justify-self: start;
}

/* ---------- the dial: one control, five signs ---------- */

.index {
  --gap: clamp(16px, 2.5vw, 40px);
  --key: 64px;
  --sign: min(40vw, 600px);
  display: grid;
  grid-template-columns: var(--sign) minmax(0, 1fr);
  grid-template-rows: var(--key) auto;
  column-gap: var(--gap);
  padding: clamp(72px, 12vw, 180px) var(--pad) clamp(72px, 10vw, 160px);
}

.dial {
  grid-column: 2;
  grid-row: 1;
  z-index: 1;
  display: flex;
  gap: 8px;
}

.dial button {
  position: relative;
  appearance: none;
  width: var(--key);
  height: var(--key);
  padding: 12px;
  border: 2px solid var(--ink);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.dial button:hover { box-shadow: inset 0 0 0 3px var(--ink); }
.dial button:active { transform: translateY(2px); }
.dial button[aria-selected="true"] { background: var(--ink); color: var(--paper); }
.dial .glyph svg { width: 100%; height: auto; }

/* One surface: the sign on the left, its name and entries on the right.
   It shares rows with the dial so the sign starts level with the keys. */
.panel {
  grid-column: 1 / -1;
  grid-row: 1 / -1;
  display: grid;
  grid-template-columns: subgrid;
  grid-template-rows: var(--key) auto 1fr;
  grid-template-areas:
    "sigil ."
    "sigil name"
    "sigil list";
}

.sigil {
  grid-area: sigil;
  position: relative;
  width: 100%;
  aspect-ratio: 1;
}

.sigil__ghost,
.sigil__ink { position: absolute; inset: 0; }
.sigil__ghost { transform: translate(5%, -4%); }
.sigil svg { width: 100%; height: auto; }

/* The name is set to fill its column, whatever the word. */
.cat-name {
  grid-area: name;
  margin: clamp(24px, 3vw, 48px) 0 0;
  padding-top: 0.1em; /* room for the ascenders under the dial */
  font-variation-settings: "wdth" 50;
  font-weight: 900;
  font-size: clamp(3rem, 10vw, 12rem); /* replaced by fitName() */
  min-width: 0;
  line-height: 0.8;
  letter-spacing: -0.015em;
  white-space: nowrap;
}

.entries {
  grid-area: list;
  align-self: end;
  list-style: none;
  margin: 32px 0 0;
  padding: 0;
  display: grid;
  gap: 0.9em;
  max-width: 30ch;
  font-variation-settings: "wdth" 125;
  font-size: clamp(1.125rem, 1.6vw, 1.5rem);
  line-height: 1.2;
}

.panel__list { grid-area: list; align-self: end; min-width: 0; }

.to-contents {
  margin: 28px 0 0;
  font-variation-settings: "wdth" 125;
  font-weight: 700;
  font-size: clamp(1rem, 1.3vw, 1.25rem);
}
.to-contents a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: inherit;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.18em;
}
.to-contents a:hover { text-decoration-thickness: 4px; }

.entries a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}
.entries a:hover { text-decoration-thickness: 3px; }

.entries .sample,
.entries .empty { font-size: 0.95rem; }
.entries .empty { font-size: inherit; }

/* Full refresh: the whole surface goes black for a beat, then repaints. */
.panel.flash { background: var(--ink); }
.panel.flash > * { visibility: hidden; }

/* ---------- back: the R faces you ---------- */

.face--back {
  grid-template-columns: auto 1fr var(--bitmap-w);
  grid-template-areas: "spine handover title";
  align-items: end;
  padding-bottom: var(--pad);
}

.face--back .bitmap { grid-area: title; }

.spine--back { transform: none; }

.handover {
  grid-area: handover;
  justify-self: end;
  text-align: right;
}

.handover__lead {
  margin: 0 0 0.6em auto;
  max-width: 18ch;
  font-variation-settings: "wdth" 150;
  font-weight: 330;
  font-size: clamp(1.25rem, 2.1vw, 2rem);
  line-height: 1.12;
}

.handover__turn {
  margin: 0;
  font-variation-settings: "wdth" 50;
  font-weight: 900;
  font-size: clamp(3.5rem, 8.5vw, 9rem);
  line-height: 0.85;
}

/* ---------- narrow screens ---------- */

@media (max-width: 760px) {
  :root { --bitmap-w: calc(100vw - 2 * var(--pad) - 76px); }

  .face--front {
    grid-template-columns: var(--bitmap-w) 1fr;
    grid-template-areas:
      "title spine"
      "statement statement";
    row-gap: 28px;
  }
  .spine { font-size: calc(var(--bitmap-w) / 1.2 / 3.75); justify-self: end; }

  .index {
    --key: 56px;
    grid-template-columns: 45% minmax(0, 1fr);
    grid-template-rows: var(--key) auto;
  }
  .dial { grid-column: 1 / -1; justify-content: space-between; gap: 6px; }
  .dial button { padding: 10px; }
  .panel {
    grid-template-rows: calc(var(--key) + 28px) auto auto;
    grid-template-areas:
      ". ."
      "sigil name"
      "list list";
  }
  .cat-name { align-self: end; margin: 0; }

  .face--back {
    grid-template-columns: 1fr var(--bitmap-w);
    grid-template-areas:
      "handover handover"
      "spine title";
    row-gap: 28px;
  }
  .handover { justify-self: stretch; }
}

@media (min-width: 761px) and (max-width: 1100px) {
  :root { --bitmap-w: 54vw; }
  .statement, .handover__lead { font-size: 1.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  .dial button:active { transform: none; }
}

/* ---------- every article, newest first ---------- */

.all { padding: 0 var(--pad) clamp(72px, 10vw, 160px); }
.all__title {
  margin: 0 0 0.4em;
  font-variation-settings: "wdth" 50;
  font-weight: 900;
  font-size: clamp(2.5rem, 7vw, 6rem);
  line-height: 0.85;
}
.all__list { list-style: none; margin: 0; padding: 0; border-top: 4px solid var(--ink); }
.all__row {
  position: relative;
  display: grid;
  grid-template-columns: 3.5ch minmax(0, 1fr) 11ch 9ch;
  align-items: baseline;
  column-gap: clamp(12px, 2.5vw, 40px);
  padding: 14px 0;
  border-bottom: 2px solid var(--ink);
}
.all__num {
  font-variation-settings: "wdth" 50;
  font-weight: 900;
  font-size: 1.75rem;
  line-height: 1;
}
.all__link {
  color: inherit;
  font-variation-settings: "wdth" 125;
  font-weight: 700;
  font-size: clamp(1.125rem, 1.8vw, 1.5rem);
  line-height: 1.15;
  text-decoration: none;
}
.all__link::after { content: ""; position: absolute; inset: 0; } /* whole row is the target */
.all__row:hover .all__link { text-decoration: underline; text-decoration-thickness: 3px; }
.all__cat { font-weight: 700; font-size: 0.9375rem; }
.all__date { font-size: 0.9375rem; text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 760px) {
  .all__row {
    grid-template-columns: 3ch minmax(0, 1fr) auto;
    row-gap: 4px;
  }
  .all__num { grid-row: 1 / 3; }
  .all__link { grid-column: 2 / 4; }
  .all__cat, .all__date { font-size: 0.875rem; }
  .all__date { text-align: right; }
}

.to-about { margin: 28px 0 0; font-variation-settings: "wdth" 125; font-weight: 700; font-size: clamp(1rem, 1.3vw, 1.25rem); }
.to-about a { display: inline-flex; align-items: center; min-height: 44px; color: inherit; text-decoration-thickness: 2px; text-underline-offset: 0.18em; }
.to-about a:hover { text-decoration-thickness: 4px; }
