/* The page's base look: tokens, the bordered sheet, masthead, title block,
   stats, section headers, tables, buttons and tabs. app.css adds what only
   this page needs.

   Dark is the default. For a light page, put class="light" on <html>. */

/* ---- Tokens ---- */

:root {
  color-scheme: dark;
  --page: #0C0C0C;
  --sheet: #151515;
  --sheet-border: #4A4A4A;
  --ink: #F2F2F2;
  --text-2: #C4C4C4;
  --label: #A3A3A3;
  --muted: #8C8C8C;
  --rule: #3D3D3D;
  --rule-light: #2E2E2E;
  --head-fill: #1F1F1F;
  --shadow: #3A3A3A;
  --btn-shadow: 2px 2px 0 var(--shadow);
  --yellow: #FFB700;
  --on-accent: #000000;
  --green: #00794C;
  --link: #8FAEFF;
  --link-hover: #BDCFFF;
  --red: #FF5A52;
  --dots: #8A8A8A;
  /* Two series side by side. */
  --series-a: #6F8FFF;
  --series-b: #FF7A3D;
  --font-ui: 'Archivo', 'Helvetica Neue', Arial, sans-serif;
  --font-data: 'Roboto Mono', Menlo, monospace;
  --snap: cubic-bezier(0.2, 0.8, 0.2, 1);
}

:root.light {
  color-scheme: light;
  --page: #EEEEEE;
  --sheet: #FFFFFF;
  --sheet-border: #888888;
  --ink: #000000;
  --text-2: #4D4D4D;
  --label: #595959;
  --muted: #6B6B6B;
  --rule: #BFBFBF;
  --rule-light: #CCCCCC;
  --head-fill: #F2F2F2;
  --shadow: #BBBBBB;
  --link: #002DCE;
  --link-hover: #001A80;
  --red: #E8110F;
  --dots: #777777;
  --series-a: #002DCE;
  --series-b: #D9480F;
}

/* ---- Base ---- */

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

html, body { margin: 0; background: var(--page); }

body {
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.4;
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3, p { margin: 0; }

a { color: var(--link); transition: color 100ms ease; }
a:hover { color: var(--link-hover); }

:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }

.mono { font-family: var(--font-data); }
.muted { color: var(--muted); }

/* ---- Motion: short, eased out, colour and position only ---- */

@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
@keyframes wipe { from { clip-path: inset(0 100% 0 0); } }

/* A page arrives top to bottom: each part a beat after the one above. */
.main > * { animation: rise 160ms var(--snap) backwards; }
.main > :nth-child(2) { animation-delay: 25ms; }
.main > :nth-child(3) { animation-delay: 50ms; }
.main > :nth-child(4) { animation-delay: 75ms; }
.main > :nth-child(n + 5) { animation-delay: 100ms; }
.halftone { animation: wipe 320ms var(--snap) backwards; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---- Page and sheet: one bordered box, 760px wide on every page ---- */

.page { min-height: 100vh; padding: 8px; }
.sheet {
  background: var(--sheet);
  border: 1px solid var(--sheet-border);
  box-shadow: 1px 1px 0 var(--rule-light);
  padding: calc(env(safe-area-inset-top, 0px) + 32px) 12px calc(env(safe-area-inset-bottom, 0px) + 16px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: calc(100vh - 16px);
}
.main { display: contents; }
@media (min-width: 600px) {
  .page { padding: 20px 16px; }
  .sheet { max-width: 760px; margin: 0 auto; padding: 36px 28px 20px; gap: 16px; min-height: calc(100vh - 40px); }
}

/* ---- Masthead: the site's name (links home), a mono label on the right ---- */

.masthead { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.masthead-title { font-size: 19px; font-weight: 800; font-stretch: 75%; letter-spacing: -0.01em; }
.masthead-title a { color: inherit; text-decoration: none; }
.masthead-title a:hover { text-decoration: underline; }
.masthead-label {
  font-family: var(--font-data); font-size: 11px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--label); text-align: right;
}

/* ---- Title over the hatched band; an optional subtitle under the title ---- */

.title-block { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.page-title { font-size: 26px; font-weight: 800; font-stretch: 75%; letter-spacing: -0.01em; line-height: 1.1; overflow-wrap: anywhere; }
.page-subtitle { font-size: 17px; font-weight: 700; line-height: 1.3; color: var(--text-2); }
.halftone {
  height: 12px;
  background: linear-gradient(135deg, transparent 44%, var(--dots) 44% 56%, transparent 56%) 0 0 / 6px 6px;
}
@media (min-width: 600px) {
  .page-title { font-size: 34px; }
  .page-subtitle { font-size: 19px; }
}

/* A line of mono facts under a title (date, reading time). */
.page-meta {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 8px; margin-top: -6px;
  font-family: var(--font-data); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--label);
}

/* ---- Stats: headline numbers as a ruled grid of cells ---- */

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--ink);
}
.stat { background: var(--sheet); padding: 8px 10px 9px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat-label { font-family: var(--font-data); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--label); }
.stat-value { font-family: var(--font-data); font-size: 22px; font-weight: 700; line-height: 1.2; white-space: nowrap; font-variant-numeric: tabular-nums; }
.stat-sub { font-family: var(--font-data); font-size: 11px; color: var(--label); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Set the column count to what divides the cells evenly: no empty cells. */
@media (min-width: 600px) {
  .stats { grid-template-columns: repeat(var(--stat-cols, 4), minmax(0, 1fr)); }
  .stat-value { font-size: 26px; }
}

/* ---- Section header: a heading over a dashed rule, mono meta on the right ---- */

.section-header {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  padding-bottom: 4px; border-bottom: 1px dashed var(--ink); margin-top: 6px;
}
.section-header h2 { font-size: 14px; font-weight: 700; }
.section-meta { font-family: var(--font-data); font-size: 11px; color: var(--label); text-align: right; overflow-wrap: anywhere; }

/* A bigger section header, for items that are the page's content (a climb, an
   exercise): condensed caps, with a label beside the name. */
.section-header.item h2 {
  font-size: 17px; font-weight: 800; font-stretch: 75%; letter-spacing: 0.01em; line-height: 1.2;
  text-transform: uppercase; overflow-wrap: anywhere;
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px;
}
@media (min-width: 600px) { .section-header.item h2 { font-size: 22px; } }

/* ---- Labels ---- */

/* The one loud label: yellow, outlined (a grade, NEW). Vertically centred. */
.label {
  font-family: var(--font-data); font-size: 12px; font-weight: 700; font-stretch: 100%; letter-spacing: 0;
  line-height: 1; padding: 3px 5px 2px;
  background: var(--yellow); color: var(--on-accent);
  outline: 1px solid var(--ink); outline-offset: -1px;
}
.label:empty { display: none; }

/* Quiet tags: mono, outlined. */
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag {
  font-family: var(--font-data); font-size: 11px; line-height: 1; padding: 3px 5px 2px;
  color: var(--text-2); outline: 1px solid var(--rule); outline-offset: -1px; white-space: nowrap;
}

/* Status badges. */
.badge { font-family: var(--font-data); font-size: 11px; color: #FFFFFF; padding: 1px 4px; white-space: nowrap; }
.badge-ok { background: var(--green); }
.badge-new { background: var(--yellow); color: var(--on-accent); outline: 1px solid var(--ink); outline-offset: -1px; }
.badge-draft { background: var(--sheet); color: var(--label); outline: 1px dashed var(--label); outline-offset: -1px; }

/* ---- Buttons: square, inked rule, offset shadow; pressed shifts into it ---- */

.btn {
  height: 32px; min-height: 32px; padding: 0 11px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--sheet); border: 1px solid var(--ink); border-radius: 0;
  box-shadow: var(--btn-shadow);
  font-family: inherit; font-size: 13px; color: var(--ink);
  text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: transform 80ms var(--snap), box-shadow 80ms var(--snap), background-color 100ms ease;
}
.btn:hover { color: var(--ink); }
@media (hover: hover) {
  .btn:hover:not(:disabled) { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--shadow); }
}
.btn:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: none; }
.btn:disabled { cursor: default; color: var(--muted); border-color: var(--muted); box-shadow: none; }
.btn-primary { background: var(--yellow); color: var(--on-accent); padding: 0 12px; }
.btn-primary:hover { color: var(--on-accent); }
.btn-primary:disabled { background: var(--sheet); }
/* A choice that is off: dashed, no shadow. */
.btn-off { border-style: dashed; box-shadow: none; color: var(--label); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* Tabs: a row of cells, the chosen one inked. */
.tabs { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); border: 1px solid var(--ink); }
.tab {
  height: 34px; border: 0; border-right: 1px solid var(--rule); background: var(--head-fill); color: var(--label);
  font-family: var(--font-data); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer;
}
.tab:last-child { border-right: 0; }
.tab[aria-selected='true'], .tab[aria-pressed='true'] { background: var(--ink); color: var(--sheet); }

/* ---- Grid table: a list of links or rows of data ---- */

.grid-table { border: 1px solid var(--rule); }
.grid-row { display: grid; border-bottom: 1px solid var(--rule); font-size: 13px; }
.grid-row:last-child { border-bottom: 0; }
.grid-row > * { padding: 0 6px; border-right: 1px solid var(--rule); display: flex; align-items: center; min-width: 0; }
.grid-row > *:last-child { border-right: 0; }
.grid-head {
  background: var(--head-fill); font-family: var(--font-data); font-size: 11px;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--label);
}
.grid-head > * { padding: 5px 6px; }
a.grid-row { min-height: 44px; color: var(--ink); text-decoration: none; transition: background-color 100ms ease; }
a.grid-row:hover { background: var(--head-fill); color: var(--ink); }
.end { justify-content: flex-end; text-align: right; }
.num { font-family: var(--font-data); font-variant-numeric: tabular-nums; }
/* The arrow after a row's link nudges right on hover. */
.go { display: inline-block; transition: transform 120ms var(--snap); }
a.grid-row:hover .go, a.grid-row:focus-visible .go { transform: translateX(4px); }
/* A row's main cell: a link and a line of mono facts under it. */
.grid-row > .cell-main { flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; padding: 8px 8px 9px; }
.row-link { color: var(--link); text-decoration: underline; font-size: 15px; font-weight: 700; overflow-wrap: anywhere; }
a.grid-row:hover .row-link { color: var(--link-hover); }
.row-meta { font-family: var(--font-data); font-size: 11px; color: var(--label); }
@media (min-width: 600px) { .grid-row > .cell-main { padding: 10px 12px 11px; } }

/* A key/value table. */
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); border: 1px solid var(--rule); }
.kv > dt, .kv > dd { margin: 0; padding: 5px 6px; border-bottom: 1px solid var(--rule); }
.kv > dt { background: var(--head-fill); border-right: 1px solid var(--rule); font-family: var(--font-data); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--label); }
.kv > dd { font-family: var(--font-data); font-size: 13px; }
.kv > :nth-last-child(-n + 2) { border-bottom: 0; }

/* ---- Box: a framed panel (a chart, a picture) ---- */

.box { border: 1px solid var(--ink); }

/* ---- NOTE box ---- */

.note { border: 1px solid var(--ink); display: flex; flex-direction: column; }
.note-tab {
  align-self: flex-start; background: var(--yellow); color: var(--on-accent); border-right: 1px solid var(--ink); border-bottom: 1px solid var(--ink);
  padding: 2px 6px; font-family: var(--font-data); font-size: 11px; letter-spacing: 0.1em; line-height: 1.4;
}
.note-body { padding: 8px; font-size: 13px; display: flex; flex-direction: column; gap: 8px; }

/* ---- Footer ---- */

.footer {
  margin-top: auto; padding-top: 10px; border-top: 1px solid var(--rule-light);
  font-family: var(--font-data); font-size: 11px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted);
}
.footer a { color: var(--muted); }
