/*
  The Grind Date (thegrinddate.com): site styles.
  Loads after /assets/site-fonts/fonts.css and /assets/base.css. base.css is
  only the reset, focus and skip-link layer here: this file sets every color
  and font role token for this site.

  The page is a punched time card: manila card stock, a printed violet ruling
  every 2.75rem (one pitch), field captions printed small in violet, entries
  typed in Courier Prime, and the owner's own Date Stamp landed across the
  card. Every block below the band is a whole number of pitches tall, so each
  typed line sits on a printed rule. The one loud thing is the stamp.

  CSP (style-src 'self'): no style elements or attributes anywhere, so every
  rule, the stamp-down animation and the punch imprint all live here.
*/

/* ---------- Tokens ---------- */
:root {
  /* Palette */
  --tgd-manila: #EBDCB2;  /* card stock, the page ground (do not lighten) */
  --tgd-folder: #DCC78F;  /* file folder tab: header and footer bands only */
  --tgd-ink: #1D1A16;     /* stamp pad ink: the stamp, typed text, heavy rules */
  --tgd-violet: #55307F;  /* methyl violet: printed captions and clock imprints */
  --tgd-ruling: #A897BF;  /* printed hairlines only, never text */

  /* Roles (base.css reads these) */
  --color-bg: var(--tgd-manila);
  --color-text: var(--tgd-ink);
  --color-muted: var(--tgd-violet);
  --color-accent: var(--tgd-violet);
  --color-rule: var(--tgd-ink);
  --color-focus: var(--tgd-ink);
  --color-on-accent: var(--tgd-manila);

  --font-display: 'Libre Franklin', 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
  --font-mono: 'Courier Prime', 'Courier New', Courier, monospace;
  --font-body: var(--font-mono);

  /* The ruling */
  --pitch: 2.75rem;           /* 44px: one ruled line */
  --sit: 0.375rem;            /* typed baselines sit this far above their rule */

  /* Type */
  --lead-size: 1.0625rem;
  --imprint-size: 1.75rem;
  --caption-size: 0.6875rem;

  /* The sheet */
  --pad-l: var(--gutter);
  --in-w: 12rem;              /* the IN column */
  --col-gap: 1.5rem;          /* entry column to the column rule */
  /* cqi: 1% of the card's width (the card is the size container) */
  --stamp-w: calc(100cqi - var(--pad-l) - var(--gutter));   /* phone: full gutter width */
}

@media (min-width: 30em) {
  :root {
    --lead-size: 1.1875rem;
    --imprint-size: 2rem;
  }
}

@media (min-width: 60em) {
  :root {
    --pad-l: clamp(2rem, 1rem + 3vw, 4.5rem);
    /* the entry column's measure, narrowed only where the IN column would
       otherwise run past the gutter (60em to about 64em) */
    --entry: min(44rem, calc(100cqi - var(--pad-l) - var(--col-gap) - var(--in-w) - var(--gutter) - 1px));
    --stamp-w: 50rem;           /* 12 pitches tall: both entries stay above the fold at 1440x900 */
  }
}

/* ---------- Page frame ---------- */
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100svh;
  background-color: var(--tgd-manila);
}

::selection {
  background-color: var(--tgd-violet);
  color: var(--tgd-manila);
}

/* ---------- Skip link: a typed entry on a folder chip ---------- */
/* shared/base.css hard-codes this link's ink, newsprint and rust; these rules
   restate it in this site's own tokens. */
.skip-link {
  background-color: var(--tgd-folder);
  color: var(--tgd-ink);
  border: 1px solid var(--tgd-ink);
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.skip-link:focus,
.skip-link:focus-visible {
  outline: var(--focus-ring) solid var(--color-focus);
  outline-offset: 2px;
}

/* ---------- Header band: the cover's own top line ---------- */
.band {
  flex-shrink: 0;
  background-color: var(--tgd-folder);
  border-bottom: 3px solid var(--tgd-ink);
}

.band-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.25rem 1.5rem;
  padding: 0.875rem var(--gutter) 0.75rem var(--pad-l);
}

.band-line {
  max-width: none;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.8125rem;
  line-height: 1.25;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* ---------- The card: printed ruling, edge to edge ---------- */
.card {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  overflow-x: clip;         /* the stamp may overhang; the page never scrolls sideways */
  container-type: inline-size;
  background-color: var(--tgd-manila);
  /* one 1px hairline at the foot of every pitch */
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent calc(var(--pitch) - 1px),
    var(--tgd-ruling) calc(var(--pitch) - 1px),
    var(--tgd-ruling) var(--pitch)
  );
}

.sheet {
  flex: 1 0 auto;
  position: relative;
  width: 100%;
  padding: var(--pitch) var(--gutter) calc(2 * var(--pitch)) var(--pad-l);
}

/* ---------- The Date Stamp (the h1) ---------- */
.stamp {
  position: relative;
  z-index: 1;               /* overprints the column rule */
  /* the h1 holds only the image: keep base.css's display face and weight off it */
  font: inherit;
  display: flex;
  align-items: center;
  /* rounded UP to whole pitches so everything below stays on the ruling */
  height: calc(var(--stamp-w) * 788 / 1200);
  height: round(up, calc(var(--stamp-w) * 788 / 1200), var(--pitch));
}

.stamp picture {
  flex: none;
}

.stamp img {
  width: var(--stamp-w);
  max-width: none;
  transform-origin: 48% 52%;
}

@media (prefers-reduced-motion: no-preference) {
  .stamp img {
    animation: stamp-down 380ms cubic-bezier(0.2, 0.8, 0.3, 1) both;
  }
}

@keyframes stamp-down {
  0% {
    opacity: 0;
    transform: scale(1.12);
  }
  70% {
    opacity: 1;
    transform: scale(0.985);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* ---------- Typed entries ---------- */
.lead {
  position: relative;
  /* drop the line so its baseline sits on the rule, not mid-pitch
     (Courier Prime: the baseline falls 0.22em below the middle of its line) */
  top: calc(var(--pitch) / 2 - 0.22 * var(--lead-size) - var(--sit));
  font-size: var(--lead-size);
  line-height: var(--pitch);
}

.lead strong {
  font-weight: 700;
}

.fields {
  margin-top: var(--pitch);
}

.field {
  position: relative;
}

/* a blank line between fields, so a caption never sits under a big imprint */
.field + .field {
  margin-top: var(--pitch);
}

/* A printed caption: small violet form gothic in the cell's top-left corner,
   hanging from the hairline above. It never adds height to the row. */
.caption,
.notfound-code {
  position: absolute;
  top: 0.1875rem;
  left: 0;
  max-width: none;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--caption-size);
  line-height: 1;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--tgd-violet);
  z-index: 1;               /* above the entry's widened hit area */
  pointer-events: none;
}

/* The time clock's imprint: violet, double struck like a ribbon print */
.status,
.entry::after {
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--tgd-violet);
  text-shadow: 0.5px 0 0 var(--tgd-violet);
}

.status {
  position: relative;
  top: calc(var(--pitch) / 2 - 0.22 * var(--imprint-size) - 0.3125rem);
  font-size: var(--imprint-size);
  line-height: var(--pitch);
}

/* The links: typed entries exactly one pitch tall. No fill, no arrow, no
   button chrome: on hover and keyboard focus the row punches IN. */
.entries li {
  position: relative;
  display: flex;            /* exactly one pitch: no line box around the entry */
  height: var(--pitch);
}

/* The entry's own box is the lower 1.5rem of its row, so the focus ring
   wraps the typed entry and never the caption printed above it; ::before
   widens the hit area back to the whole row. The side padding (pulled back
   on the left) gives the ring room without moving the typed margin. */
.entry {
  display: inline-flex;
  align-self: flex-end;
  align-items: flex-end;
  gap: 0.625rem;
  height: 1.5rem;
  margin-left: -0.375rem;
  padding: 0 0.375rem 1px;
  font-weight: 700;
  font-size: var(--lead-size);
  line-height: 1;
  text-decoration: none;
  color: var(--tgd-ink);
}

.entry::before {
  content: '';
  position: absolute;
  inset: 0;
}

.entry .icon {
  width: 1.125em;
  height: 1.125em;
  margin-bottom: 0.125em;
  vertical-align: 0;
}

.entry:hover {
  color: var(--tgd-ink);
}

.entry:focus-visible {
  outline: var(--focus-ring) solid var(--tgd-ink);
  outline-offset: 2px;
}

/* The punch: phone puts it at the right end of the entry's own line */
.entry:hover::after,
.entry:focus-visible::after {
  content: 'In';
  content: 'In' / '';
  position: absolute;
  right: 0;
  bottom: 1px;
  font-size: 1.5rem;
  line-height: 1;
}

/* ---------- Footer: the form's bottom border and fine print ---------- */
.fine-print {
  flex-shrink: 0;
  /* a double rule: 2px, a 2px gap, then 1px */
  background:
    linear-gradient(
      to bottom,
      var(--tgd-ink) 0 2px,
      transparent 2px 4px,
      var(--tgd-ink) 4px 5px,
      transparent 5px
    ) top left / 100% 5px no-repeat,
    var(--tgd-folder);
}

.fine-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 2rem;
  padding: 1.25rem var(--gutter) 1.5rem var(--pad-l);
  font-size: 0.9375rem;
  line-height: 1.5;
}

.credit {
  max-width: 52ch;
}

.credit cite {
  font-style: italic;
}

.show-of {
  max-width: none;
}

.show-of a {
  display: inline-block;
  padding-block: 0.375rem;
  font-weight: 700;
  text-decoration-color: var(--tgd-ink);
  text-decoration-thickness: 1px;
}

.show-of a:hover {
  color: var(--tgd-violet);
  text-decoration-color: var(--tgd-violet);
}

/* ---------- 404 ---------- */
/* Row 1 holds the printed form number (the caption), row 2 the title, typed
   onto its rule as an ink imprint: the card's own typewriter, never a heavy
   gothic headline (that is averagejoechess.com's voice, not this card's). */
.notfound .sheet {
  padding-top: 0;
}

.notfound-code {
  position: static;
  height: var(--pitch);
  padding-top: 0.1875rem;
}

.notfound h1 {
  --h1-size: clamp(1.75rem, 1.2rem + 2.6vw, 2.5rem);
  position: relative;
  /* Courier Prime: the baseline falls 0.22em below the middle of its line */
  top: calc(var(--pitch) / 2 - 0.22 * var(--h1-size) - var(--sit));
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: var(--h1-size);
  line-height: var(--pitch);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--tgd-ink);
  /* double struck, like the clock's imprint, in ink */
  text-shadow: 0.5px 0 0 var(--tgd-ink);
}

.notfound-text {
  margin-top: var(--pitch);
}

.notfound .entries {
  margin-top: var(--pitch);
}

/* ---------- Wider screens: the IN column ---------- */
/* Left anchored. The entry column is a fixed measure, the 12rem IN column
   follows it between two rules, and the card runs on, ruled, to the edge.
   The stamp is wider than the entry column, so it crosses the column rule. */
@media (min-width: 60em) {
  .band-line {
    font-size: 0.9375rem;
  }

  .lead,
  .entries li {
    max-width: var(--entry);
  }

  /* the IN column, ruled on both sides in the ruling color */
  .sheet::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: calc(var(--pad-l) + var(--entry) + var(--col-gap));
    width: calc(var(--in-w) + 1px);
    border-inline: 1px solid var(--tgd-ruling);
  }

  /* the column's printed head: a caption, decorative, skipped by screen readers */
  .sheet::after {
    content: 'In';
    content: 'In' / '';
    position: absolute;
    top: 0.1875rem;
    left: calc(var(--pad-l) + var(--entry) + var(--col-gap) + 0.625rem);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: var(--caption-size);
    line-height: 1;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--tgd-violet);
  }

  /* a stamp never lands square: a little right of the typed margin */
  .stamp img {
    margin-left: 0.5rem;
  }

  /* The punch lands in the IN column on the row's own line */
  .entry:hover::after,
  .entry:focus-visible::after {
    right: auto;
    left: calc(100% + var(--col-gap));
    width: var(--in-w);
    text-align: center;
  }
}
