/* Growbro Cup.
 *
 * The look of Growbro, its sibling app: paper ground, deep forest green,
 * square corners, a serif for titles and figures, sans and mono for the
 * rest. Two layouts share it: the sheet a participant's phone shows after a
 * scan, and the wider pages the organiser works in.
 *
 * Sections: tokens · reset · sheet · organiser layout · messages · buttons ·
 * forms · scale · tables · results · qr sheet · print.
 */

/* ---------------------------------------------------------------- tokens */

:root {
    --paper: #F2F0E9;
    --surface: #FBFAF6;
    --surface-alt: #F5F3EB;
    --head: #EFEDE4;

    --ink: #1A211C;
    --ink-2: #4A5750;
    --ink-3: #656E67;      /* muted body text, >=4.9:1 on --surface */
    --ink-label: #56635B;  /* micro labels on --head, >=5.5:1 */

    --rule: #D9D5C8;
    --rule-soft: #EAE7DC;

    --green: #14432A;
    --green-dark: #0C2C1B;
    --green-pale: #E7EFE8;
    --green-line: #3C6A50;

    --gold: #8A6A12;
    --danger: #8C2F1D;
    --flag: #A8471E;

    --serif: 'Fraunces', Georgia, 'Times New Roman', serif;
    --sans: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
    --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', monospace;
}

/* ----------------------------------------------------------------- reset */

*, *::before, *::after { box-sizing: border-box; border-radius: 0; }
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
    background: var(--paper);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 14px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--green); text-decoration: none; }
a:hover { color: var(--green-dark); text-decoration: underline; }

h1, h2, h3, p, ul, ol, dl, dd { margin: 0; }
ul, ol { list-style: none; padding: 0; }
table { border-collapse: collapse; width: 100%; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }

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

.mono { font-family: var(--mono); }
.cup-visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--ink-3); }

/* ----------------------------------------------------------------- sheet */

/* What a participant's phone shows: one column, nothing to the side. */
.cup-sheetpage { min-height: 100vh; display: flex; justify-content: center; padding: 24px 16px 40px; }
.cup-sheet { width: 100%; max-width: 440px; border: 1px solid var(--rule); background: var(--surface); padding: 26px 22px 28px; align-self: flex-start; }
.cup-sheet--wide { max-width: 640px; }
.cup-mark { font-family: var(--serif); font-size: 26px; font-weight: 600; letter-spacing: -0.02em; color: var(--green); line-height: 1.15; }
.cup-sub { font-family: var(--mono); font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-3); margin: 4px 0 22px; }
.cup-sample { font-family: var(--serif); font-size: 40px; font-weight: 500; line-height: 1; color: var(--ink); margin-bottom: 6px; }
.cup-sample__label { font-family: var(--mono); font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-3); display: block; margin-bottom: 4px; }
.cup-lead { font-size: 13.5px; color: var(--ink-2); margin-bottom: 20px; }
.cup-foot { margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--rule); font-size: 12px; color: var(--ink-3); }
.cup-foot strong { color: var(--ink-2); font-weight: 600; }

/* ------------------------------------------------------ organiser layout */

.cup-topbar {
    display: flex; align-items: center; gap: 22px; flex-wrap: wrap;
    padding: 14px 26px; border-bottom: 1px solid var(--rule); background: var(--paper);
}
.cup-topbar .cup-mark { font-size: 21px; }
.cup-topbar .cup-mark:hover { text-decoration: none; color: var(--green-dark); }
.cup-topbar__nav { display: flex; gap: 18px; align-items: center; margin-left: auto; font-size: 13px; }
.cup-topbar__nav form { margin: 0; }

.cup-main { padding: 26px 26px 40px; max-width: 1200px; }
.cup-main--narrow { max-width: 720px; }

.cup-pagehead { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.cup-pagehead__title { font-family: var(--serif); font-size: 30px; font-weight: 400; letter-spacing: -0.01em; line-height: 1.1; }
.cup-pagehead__meta { font-family: var(--mono); font-size: 11px; color: var(--ink-3); margin-top: 6px; }
.cup-pagehead__actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.cup-section { margin-top: 30px; }
.cup-section__title { font-family: var(--mono); font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 10px; display: flex; gap: 10px; align-items: baseline; }
.cup-section__title span { letter-spacing: 0.04em; text-transform: none; font-size: 11px; }

.cup-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--rule); border: 1px solid var(--rule); }
.cup-stat { background: var(--surface); padding: 12px 14px; }
.cup-stat__value { font-family: var(--serif); font-size: 26px; line-height: 1.1; }
.cup-stat__label { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-label); margin-top: 4px; }

.cup-status { display: inline-block; font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; padding: 3px 7px; border: 1px solid var(--green-line); color: var(--green); background: var(--green-pale); }
.cup-status--closed { border-color: var(--rule); color: var(--ink-2); background: var(--head); }

.cup-empty { padding: 26px; border: 1px dashed var(--rule); text-align: center; color: var(--ink-3); background: var(--surface); }

/* -------------------------------------------------------------- messages */

.cup-messages { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.cup-message { padding: 9px 12px; border-left: 3px solid var(--ink-3); background: var(--surface); font-size: 13px; }
.cup-message--success { border-left-color: var(--green); background: var(--green-pale); color: var(--green-dark); }
.cup-message--error { border-left-color: var(--danger); background: #F7EBE7; color: #6E2416; }
.cup-message--warning { border-left-color: var(--flag); background: #F8EFE6; color: #6B2E11; }

/* --------------------------------------------------------------- buttons */

.cup-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 8px 15px; border: 1px solid var(--green); background: var(--green); color: var(--paper);
    font-family: var(--sans); font-size: 12.5px; font-weight: 500; line-height: 1.3;
    cursor: pointer; text-decoration: none;
}
.cup-btn:hover { background: var(--green-dark); border-color: var(--green-dark); color: var(--paper); text-decoration: none; }
.cup-btn--ghost { background: transparent; border-color: var(--rule); color: var(--ink-2); }
.cup-btn--ghost:hover { background: var(--surface-alt); border-color: var(--ink-3); color: var(--ink); }
.cup-btn--danger { background: var(--danger); border-color: var(--danger); }
.cup-btn--danger:hover { background: #6E2416; border-color: #6E2416; }
.cup-btn--block { width: 100%; padding: 12px 15px; font-size: 14px; }

.cup-linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--green); cursor: pointer; }
.cup-linkbtn:hover { color: var(--green-dark); text-decoration: underline; }
.cup-linkbtn--danger { color: var(--danger); }

/* ----------------------------------------------------------------- forms */

.cup-fields { display: flex; flex-direction: column; gap: 16px; }
.cup-fieldrow { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }
.cup-field { display: flex; flex-direction: column; }
.cup-label { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-label); margin-bottom: 6px; }
.cup-help { font-size: 11.5px; color: var(--ink-3); margin-top: 5px; }
.cup-field input[type="text"], .cup-field input[type="number"], .cup-field input[type="password"] {
    width: 100%; padding: 9px 10px; background: var(--surface); border: 1px solid var(--rule);
    color: var(--ink); font-family: var(--sans); font-size: 16px;
}
.cup-field input:focus { outline: none; border-color: var(--green); box-shadow: inset 0 -2px 0 var(--green); }
.cup-error { margin-top: 5px; font-size: 12.5px; color: var(--danger); }
.cup-formerror { padding: 10px 12px; border-left: 3px solid var(--danger); background: #F7EBE7; color: #6E2416; font-size: 13px; }
.cup-weightsum { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.cup-weightsum.is-off { color: var(--danger); }

.cup-fieldset { border-top: 1px solid var(--rule); padding-top: 14px; }
.cup-legend { float: left; width: 100%; font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-label); padding: 0 0 8px; }
.cup-legend + * { clear: both; }

/* ----------------------------------------------------------------- scale */

/* Nine squares in a row, the whole row tappable: on a 360px phone each is
   about 34px wide, near the 44px a thumb wants and wider than a radio. */
.cup-crit { border-top: 1px solid var(--rule); padding: 14px 0 4px; }
.cup-crit:first-of-type { border-top: 0; padding-top: 0; }
/* A legend sits on its fieldset's top border, so every row after the first
   (which has none) stood 15px lower than the first. Floated, it is an
   ordinary box inside the fieldset. */
.cup-crit__name { float: left; font-family: var(--serif); font-size: 19px; font-weight: 500; padding: 0; margin-bottom: 8px; display: flex; align-items: baseline; width: 100%; }
.cup-crit__weight { margin-left: auto; font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em; color: var(--ink-3); font-weight: 400; }
/* What a criterion takes in, under its name: three criteria hold what
   used to be eight, and everyone has to judge the same things. */
.cup-crit__hint { clear: both; font-size: 12px; line-height: 1.4; color: var(--ink-3); margin: -4px 0 9px; }
.cup-scale { clear: both; display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 3px; }
.cup-scale label { position: relative; display: block; }
.cup-scale input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.cup-scale span {
    display: flex; align-items: center; justify-content: center; height: 42px;
    border: 1px solid var(--rule); background: var(--paper);
    font-family: var(--mono); font-size: 15px; font-weight: 500; color: var(--ink-2);
    cursor: pointer; user-select: none;
}
.cup-scale label:hover span { border-color: var(--green-line); }
.cup-scale input:checked + span { background: var(--green); border-color: var(--green); color: var(--paper); }
.cup-scale input:focus-visible + span { outline: 2px solid var(--green); outline-offset: 2px; }
.cup-scale__ends { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-3); margin-top: 4px; }

/* ---------------------------------------------------------------- tables */

/* Positioned, so a visually hidden header label inside is held by the
   scrolling box: unheld, it hung off the document and widened the page by
   400px on a phone. */
.cup-tablewrap { position: relative; overflow-x: auto; border: 1px solid var(--rule); background: var(--surface); }
.cup-table { font-size: 13px; }
.cup-table th {
    text-align: left; padding: 8px 10px; background: var(--head); border-bottom: 1px solid var(--rule);
    font-family: var(--mono); font-size: 9.5px; font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-label);
    white-space: nowrap;
}
.cup-table td { padding: 7px 10px; border-bottom: 1px solid var(--rule-soft); vertical-align: middle; }
.cup-table tbody tr:last-child td { border-bottom: 0; }
.cup-table tbody tr:nth-child(even) td { background: var(--surface-alt); }
.cup-table .num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cup-table th.num { text-align: right; }
.cup-table .center { text-align: center; }
.cup-table .fit { width: 1%; white-space: nowrap; }
.cup-table tfoot td { background: var(--head); font-family: var(--mono); font-size: 11px; color: var(--ink-3); border-top: 1px solid var(--rule); border-bottom: 0; }
.cup-table .name { font-weight: 600; }

/* The who-rated-what grid: a filled cell is a rating, an empty one a gap. */
.cup-grid td.cell { text-align: center; font-family: var(--mono); font-size: 12px; min-width: 48px; }
.cup-grid td.cell--done { color: var(--green-dark); }
.cup-grid td.cell--done span { display: inline-block; padding: 2px 5px; background: var(--green-pale); border: 1px solid #C9DCCD; }
.cup-grid td.cell--missing { color: var(--rule); }
.cup-grid td.cell--missing span { color: var(--flag); }
.cup-grid tr.is-complete td.name::after { content: " \2713"; color: var(--green-line); font-weight: 400; }

.cup-meter { display: inline-block; width: 70px; height: 6px; background: var(--rule-soft); vertical-align: middle; margin-right: 8px; }
.cup-meter span { display: block; height: 100%; background: var(--green-line); }

/* --------------------------------------------------------------- results */

.cup-ranking { display: flex; flex-direction: column; gap: 8px; }
.cup-place { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; column-gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--rule); background: var(--surface); }
.cup-place.is-current { border-color: var(--green-line); box-shadow: inset 3px 0 0 var(--green); }
.cup-place__rank { font-family: var(--serif); font-size: 24px; line-height: 1; color: var(--ink-3); text-align: center; }
.cup-place--1 .cup-place__rank { color: var(--gold); font-weight: 600; }
.cup-place__name { font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.cup-place__sub { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); margin-top: 2px; }
.cup-place__total { font-family: var(--serif); font-size: 24px; line-height: 1; text-align: right; }
.cup-place__total small { display: block; font-family: var(--mono); font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); margin-top: 3px; }
.cup-place__crits { grid-column: 2 / -1; display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; font-size: 11.5px; color: var(--ink-2); }
.cup-place__crits b { font-family: var(--mono); font-weight: 500; color: var(--ink); }

/* -------------------------------------------------------------- qr sheet */

.cup-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.cup-card { border: 1px dashed var(--ink-3); background: #fff; padding: 12px 12px 10px; text-align: center; break-inside: avoid; page-break-inside: avoid; }
.cup-card__cup { font-family: var(--mono); font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase; color: #333; overflow-wrap: anywhere; }
.cup-card__num { font-family: var(--serif); font-size: 30px; line-height: 1.05; color: #000; margin: 2px 0 6px; }
.cup-qr { display: block; width: 100%; max-width: 160px; height: auto; margin: 0 auto; }
.cup-card__hint { font-size: 10px; color: #333; margin-top: 4px; }

/* ----------------------------------------------------------------- print */

@media print {
    body { background: #fff; }
    .cup-topbar, .cup-noprint, .cup-messages { display: none !important; }
    .cup-main { padding: 0; max-width: none; }
    .cup-cards { grid-template-columns: repeat(3, 1fr); gap: 6mm; }
    .cup-card { border-color: #999; }
}

@media (max-width: 600px) {
    .cup-topbar { padding: 12px 16px; gap: 10px; }
    .cup-main { padding: 20px 16px 32px; }
    .cup-pagehead__title { font-size: 25px; }
    .cup-pagehead__actions { margin-left: 0; }
}
