/*
  SwordzDance. The site is the game's own notice board: sheets of rag paper nailed to dark timber, printed in black ink
  with one second colour (the red a printer keeps for what matters). Type: IM Fell English for names and headings,
  Alegreya Sans for everything read at speed. Both under the SIL Open Font License (assets/fonts).

  The one loud thing is the cut across the first bill. Everything else keeps still.
*/

@font-face { font-family: "Fell"; src: url("fonts/IMFellEnglish-Regular.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Fell"; font-style: italic; src: url("fonts/IMFellEnglish-Italic.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Alegreya Sans"; src: url("fonts/AlegreyaSans-Regular.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Alegreya Sans"; font-weight: 700; src: url("fonts/AlegreyaSans-Bold.ttf") format("truetype"); font-display: swap; }

:root {
  --timber: #2b2019;
  --timber-seam: #1a130e;
  --paper: #cdbf9e;
  --paper-foot: #bfae8a;
  --slip: #ddd1b4;
  --ink: #1b1613;
  --ink-soft: #594c40;
  --ink-faint: #8c7d67;
  --rubric: #991f14;
  --rubric-deep: #5e120b;
  --on-timber: #cdbf9e;

  --display: "Fell", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --text: "Alegreya Sans", "Gill Sans", "Trebuchet MS", sans-serif;

  /* A scale in fifths from an 18px body (1.5 ratio above it, 0.85 steps below). */
  --s-small: 0.89rem;
  --s-body: 1.125rem;
  --s-lead: 1.5rem;
  --s-h3: 1.6rem;
  --s-h2: clamp(2.1rem, 1.4rem + 2.6vw, 3.4rem);
  --s-title: clamp(2.6rem, 0.4rem + 11.6vw, 11rem);

  --gutter: clamp(1rem, 4vw, 3.5rem);
  --pad: clamp(1.4rem, 3.4vw, 3.2rem);
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  color: var(--ink);
  font: var(--s-body)/1.5 var(--text);
  background-color: var(--timber);
  /* Planks: a seam every so often, and the grain running along them. */
  background-image:
    repeating-linear-gradient(to bottom, transparent 0 13.4rem, var(--timber-seam) 13.4rem 13.55rem, rgba(255, 235, 200, 0.045) 13.55rem 13.62rem),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='900' height='430'%3E%3Cfilter id='g' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.0035 0.42' numOctaves='4' seed='11' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.05  0 0 0 0 0.03  0 0 0 0 0.02  0 0 0 1.5 -0.42'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
  background-size: auto, 900px 430px;
}

a { color: inherit; text-decoration-color: var(--rubric); text-decoration-thickness: 0.09em; text-underline-offset: 0.18em; }
a:hover { color: var(--rubric); }

:focus-visible { outline: 3px solid var(--rubric); outline-offset: 3px; }
.strip :focus-visible, .foot :focus-visible { outline-color: var(--paper); }

.skip { position: absolute; left: -999rem; top: 0.5rem; background: var(--slip); color: var(--ink); padding: 0.5rem 0.9rem; z-index: 10; }
.skip:focus { left: 0.5rem; }

/* ---------------------------------------------------------------- the strip of names along the top of the board */

.strip {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.3rem 1.7rem;
  padding: 1.3rem var(--gutter) 0;
  color: var(--on-timber);
  font-size: 1.05rem;
}
.strip a { text-decoration: none; padding: 0.2rem 0; border-bottom: 2px solid transparent; }
.strip a:hover { color: #fff3d6; border-bottom-color: var(--rubric); }
.strip__name { font: 1.5rem/1 var(--display); margin-right: auto; }

/* ---------------------------------------------------------------- a bill: one sheet nailed to the board */

main { padding: clamp(1.2rem, 3vw, 2.6rem) var(--gutter) 0; max-width: 92rem; margin: 0 auto; }

.bill {
  position: relative;
  padding: var(--pad);
  color: var(--ink);
  background-color: var(--paper);
  /* Four nails, the cloudy pulp of the paper, and its handled edges. */
  background-image:
    radial-gradient(circle at 15px 15px, #0d0a08 0 3.5px, rgba(0, 0, 0, 0.25) 4px 5px, transparent 5.5px),
    radial-gradient(circle at calc(100% - 15px) 15px, #0d0a08 0 3.5px, rgba(0, 0, 0, 0.25) 4px 5px, transparent 5.5px),
    radial-gradient(circle at 15px calc(100% - 15px), #0d0a08 0 3.5px, rgba(0, 0, 0, 0.25) 4px 5px, transparent 5.5px),
    radial-gradient(circle at calc(100% - 15px) calc(100% - 15px), #0d0a08 0 3.5px, rgba(0, 0, 0, 0.25) 4px 5px, transparent 5.5px),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='520' height='520'%3E%3Cfilter id='p' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.0077' numOctaves='4' seed='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.3  0 0 0 0 0.22  0 0 0 0 0.12  0 0 0 0.5 -0.17'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23p)'/%3E%3C/svg%3E"),
    linear-gradient(to bottom, transparent 55%, rgba(120, 96, 58, 0.16));
  box-shadow: inset 0 0 2.4rem rgba(96, 72, 40, 0.22), 0.45rem 0.7rem 0 rgba(0, 0, 0, 0.3), 0.9rem 1.5rem 2.2rem rgba(0, 0, 0, 0.35);
  transform: rotate(var(--tilt, 0deg));
}

.row { display: grid; gap: clamp(1.4rem, 3vw, 3rem); margin-top: clamp(2.2rem, 5vw, 4.5rem); align-items: start; }

h2 { font: 400 var(--s-h2)/1.05 var(--display); margin: 0 0 0.6em; letter-spacing: -0.005em; }
h2::after { content: ""; display: block; margin-top: 0.32em; height: 0.34rem; border-top: 0.2rem solid var(--ink); border-bottom: 1px solid var(--ink); }
h3 { font: 400 var(--s-h3)/1.15 var(--display); margin: 0 0 0.5em; }

p { margin: 0 0 1em; max-width: 36em; }
.intro { font-size: var(--s-lead); line-height: 1.35; max-width: 27em; }
.after { margin: 1.6em 0 0; color: var(--ink-soft); }

/* ---------------------------------------------------------------- the first bill */

.bill--hero { --tilt: -0.5deg; padding-bottom: calc(var(--pad) * 0.9); }

.plate { position: relative; margin: calc(var(--pad) * -0.35) calc(var(--pad) * -0.35) 0; touch-action: pan-y; cursor: crosshair; user-select: none; -webkit-user-select: none; }
/* The printing on the sheet, in two copies once it is cut: each keeps its side of the line and they draw apart. */
.plate__half { position: relative; padding: calc(var(--pad) * 0.35) calc(var(--pad) * 0.35) 0.2rem; will-change: transform; }
.plate__half--b { position: absolute; inset: 0; }
/* The cut, its scars and the flash of the blade are drawn over the printing. */
.plate__marks { position: absolute; inset: 0; width: 100%; height: 100%; overflow: hidden; pointer-events: none; }
.plate__marks polygon { filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.45)); }
.plate__marks .scar { stroke: var(--rubric); stroke-width: 1.6; opacity: 0.5; }
.plate__marks .flash { stroke: #fff6e0; stroke-width: 3; stroke-linecap: round; fill: none; filter: drop-shadow(0 0 5px rgba(255, 246, 224, 0.9)); }

.title {
  font: 400 var(--s-title)/0.92 var(--display);
  margin: 0;
  letter-spacing: -0.018em;
  /* (The face's own long descender on the z must not be clipped by the line box.) */
  padding-bottom: 0.08em;
  white-space: nowrap;
}
.title span { display: inline-block; }
.lede { font: italic clamp(1.35rem, 0.9rem + 1.7vw, 2.3rem)/1.2 var(--display); margin: 0.15em 0 0; max-width: none; }
.plate::after { content: ""; display: block; margin: clamp(0.9rem, 2vw, 1.5rem) calc(var(--pad) * 0.35) 0; height: 0.42rem; border-top: 0.26rem solid var(--ink); border-bottom: 1px solid var(--ink); }

.reading { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.4rem 2rem; align-items: start; margin-top: clamp(1rem, 2vw, 1.6rem); min-height: 8.6rem; }
.reading__ask { grid-column: 1; margin: 0; color: var(--ink-soft); }
.reading__figures { grid-column: 1; display: flex; flex-wrap: wrap; gap: 0.2rem clamp(1.4rem, 4vw, 3.4rem); margin: 0; }
.reading__figures dt { font-size: var(--s-small); color: var(--ink-soft); }
.reading__figures dd { margin: 0; font: 700 clamp(1.9rem, 1.3rem + 2vw, 2.9rem)/1 var(--text); font-variant-numeric: tabular-nums; }
.reading__figures dd small { font-size: 0.45em; font-weight: 400; color: var(--ink-soft); margin-left: 0.15em; }
.reading__verdict { grid-column: 1; margin: 0.35rem 0 0; font: italic var(--s-lead)/1.25 var(--display); max-width: 30em; min-height: 2.5em; }
.reading__verdict:empty { display: none; }
#cut-for-me { grid-column: 2; grid-row: 1 / span 3; align-self: start; }

.get { display: flex; flex-wrap: wrap; align-items: center; gap: 0.9rem 1.1rem; margin-top: clamp(1.2rem, 2.4vw, 2rem); padding-top: clamp(1.1rem, 2vw, 1.6rem); border-top: 1px solid var(--ink-faint); }
.get__note { margin: 0 0 0 0.4rem; color: var(--ink-soft); }

/* ---------------------------------------------------------------- buttons: a block of ink, and a slip of paper */

.block, .tag { display: inline-block; font: 700 1.15rem/1.1 var(--text); text-decoration: none; border-radius: 3px; cursor: pointer; transition: background-color 0.16s, transform 0.08s, box-shadow 0.08s; }
.block { color: var(--paper); background: var(--ink); padding: 0.95rem 1.5rem; border: 0; box-shadow: 0.2rem 0.26rem 0 rgba(0, 0, 0, 0.3); }
.block:hover { color: var(--paper); background: var(--rubric); }
.tag { color: var(--ink); background: var(--slip); padding: 0.62rem 1.05rem; border: 0.1rem solid var(--ink); box-shadow: 0.16rem 0.2rem 0 rgba(0, 0, 0, 0.25); font-size: 1rem; }
.tag:hover { background: #cabb97; }
.block:active, .tag:active { transform: translate(0.14rem, 0.18rem); box-shadow: 0.04rem 0.06rem 0 rgba(0, 0, 0, 0.3); }

/* ---------------------------------------------------------------- how a blow is judged */

#judged { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
#judged .bill--wide { --tilt: 0.35deg; }

.points { margin: 1.8rem 0 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 clamp(1.4rem, 3vw, 3rem); }
.points > div { padding: 1.05rem 0 1.15rem; border-top: 1px solid var(--ink-faint); }
.points dt { font: 400 var(--s-h3)/1.15 var(--display); margin-bottom: 0.3rem; }
.points dd { margin: 0; max-width: 24em; }

.bill--print { --tilt: -1.3deg; margin: clamp(1.5rem, 5vw, 5rem) 0 0; padding: clamp(0.9rem, 1.8vw, 1.5rem) clamp(0.9rem, 1.8vw, 1.5rem) 1.1rem; }
.bill--print img { display: block; width: 100%; height: auto; border: 1px solid var(--ink); }
.bill--print figcaption { font: italic 1.2rem/1.3 var(--display); margin-top: 0.8rem; padding: 0 0.3rem; }

/* ---------------------------------------------------------------- armoury */

.row--armoury { grid-template-columns: minmax(0, 1fr); justify-items: end; }
.row--armoury .bill { --tilt: -0.3deg; width: min(100%, 58rem); }

.ledger { width: 100%; border-collapse: collapse; margin-top: 1.6rem; }
.ledger th, .ledger td { text-align: left; vertical-align: baseline; padding: 0.72rem 1.4rem 0.72rem 0; border-bottom: 1px solid var(--ink-faint); }
.ledger thead th { font: 400 var(--s-small)/1.2 var(--text); color: var(--ink-soft); padding-bottom: 0.45rem; }
.ledger tbody th { font: 400 var(--s-h3)/1.1 var(--display); white-space: nowrap; }
.ledger .num { text-align: right; padding-right: 0; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ledger tbody .num { font-weight: 700; }

/* ---------------------------------------------------------------- download and install */

.row--play .bill { --tilt: 0.25deg; }
.ways { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(1.6rem, 4vw, 4rem); margin-top: 1.4rem; }
.way ol { margin: 0 0 1.5rem; padding: 0; list-style: none; counter-reset: step; }
.way li { counter-increment: step; position: relative; padding: 0.7rem 0 0.75rem 2.6rem; border-top: 1px solid var(--ink-faint); max-width: 32em; }
.way li::before { content: counter(step); position: absolute; left: 0.1rem; top: 0.62rem; font: 700 1.5rem/1 var(--text); color: var(--rubric); }
code { font: 0.92em/1 ui-monospace, "Cascadia Mono", Consolas, monospace; background: rgba(27, 22, 19, 0.09); padding: 0.12em 0.36em; border-radius: 2px; }

/* ---------------------------------------------------------------- what changed */

.row--changes { grid-template-columns: minmax(0, 1fr); }
.row--changes .bill { --tilt: -0.2deg; width: min(100%, 52rem); }
.changelog__entry + .changelog__entry { margin-top: 2.2rem; padding-top: 1.6rem; border-top: 1px solid var(--ink-faint); }
.changelog h3 { font: 700 1.45rem/1.2 var(--text); margin-bottom: 0.7em; }
.changelog h4 { font: 700 1.1rem/1.2 var(--text); margin: 1.2em 0 0.35em; }
.changelog ul { margin: 0 0 1em; padding-left: 1.15em; max-width: 38em; }
.changelog li { margin-bottom: 0.3em; }
.changelog li::marker { color: var(--rubric); }
.changelog__wait { color: var(--ink-soft); }
.changelog__more { margin-top: 1.6rem; }

/* ---------------------------------------------------------------- the foot of the board */

.foot { color: var(--on-timber); padding: clamp(3rem, 7vw, 6rem) var(--gutter) 3rem; max-width: 92rem; margin: 0 auto; }
.foot p { margin: 0 0 0.4rem; max-width: 40em; }
.foot p:first-child { font: 1.5rem/1.2 var(--display); margin-bottom: 0.6rem; }
.foot a:hover { color: #fff3d6; }

/* ---------------------------------------------------------------- the one orchestrated moment: the title is printed, then cut */

@keyframes strike-letter {
  from { opacity: 0; transform: translateY(0.07em) scale(1.06); filter: blur(3px); }
  to { opacity: 1; transform: none; filter: none; }
}
.title.is-printing span { opacity: 0; animation: strike-letter 0.34s cubic-bezier(0.2, 0.8, 0.2, 1) forwards; animation-delay: calc(var(--i) * 55ms + 120ms); }

@keyframes fade { to { opacity: 0; } }
.plate__marks .flash { animation: fade 0.5s 0.05s ease-out forwards; }

/* ---------------------------------------------------------------- narrower boards */

@media (max-width: 60rem) {
  #judged { grid-template-columns: minmax(0, 1fr); }
  .bill--print { margin-top: 0; width: min(100%, 34rem); justify-self: end; }
  .ways { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 40rem) {
  :root { --s-body: 1.06rem; --s-lead: 1.28rem; }
  .bill { --tilt: 0deg !important; }
  .strip { gap: 0.2rem 1.1rem; font-size: 1rem; }
  .strip__name { flex-basis: 100%; }
  .points { grid-template-columns: minmax(0, 1fr); }
  .reading { grid-template-columns: minmax(0, 1fr); min-height: 11.5rem; }
  #cut-for-me { grid-column: 1; grid-row: auto; justify-self: start; margin-top: 0.5rem; }
  .get__note { margin-left: 0; flex-basis: 100%; }
  .block { width: 100%; text-align: center; }
  .ledger th, .ledger td { padding-right: 0.8rem; }
  .ledger thead th:nth-child(2), .ledger tbody td:nth-child(2) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .title.is-printing span { opacity: 1; animation: none; }
  .plate__half { transition: none !important; }
  .plate__marks .flash { display: none; }
  .block, .tag { transition: none; }
}
