/* Shared by every page.
   Look: a measuring tape across the top (throws are measured with a steel tape),
   concrete-grey ground, plain white panels. The tape is the one loud element. */

:root {
    --concrete: #e2e4e1;      /* page background, like a throwing circle */
    --panel: #fbfbf9;         /* panels and dialogs */
    --ink: #1f262a;           /* text, rules, tick marks */
    --muted: #5b6569;         /* secondary text */
    --tape: #f22e2e;          /* measuring-tape yellow */
    --tape-deep: #dc1313;     /* tape yellow, pressed */
    --sector: #b3332a;        /* sector-flag red: errors and deleting */
    --line: #cfd4d2;          /* light rules between rows */
    --line-strong: #98a2a5;   /* input borders */
    --focus: #1d5fa6;

    --display: "Barlow Condensed", "Arial Narrow", sans-serif;
    --body: "Barlow", system-ui, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    font-family: var(--body);
    font-size: 1.0625rem;
    line-height: 1.5;
    color: var(--ink);
    background: var(--concrete);
    margin: 0;
}

/* ---- The tape: nav bar with tick marks along its bottom edge ---- */

nav {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 1.5rem;
    background: var(--tape);
    padding: 0.7rem 1.5rem 1.35rem;
}

/* Minor ticks every 12px, major ticks every 60px, like inch/foot marks */
nav::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 12px;
    background:
        repeating-linear-gradient(90deg, var(--ink) 0 2px, transparent 2px 60px) left bottom / 100% 12px no-repeat,
        repeating-linear-gradient(90deg, var(--ink) 0 1px, transparent 1px 12px) left bottom / 100% 6px no-repeat;
    pointer-events: none;
}

.brand {
    font-family: var(--display);
    font-weight: 700;
    font-size: 1.45rem;
    margin-right: auto;
}

nav a {
    font-family: var(--display);
    font-weight: 600;
    font-size: 1.2rem;
    color: var(--ink);
    text-decoration: none;
    border-bottom: 3px solid transparent;
}

nav a:hover,
nav a[aria-current="page"] {
    border-bottom-color: var(--ink);
}

/* ---- Page layout ---- */

main {
    max-width: 1040px;
    margin: 0 auto;
    padding: 1.5rem 1.5rem 3rem;
}

h1,
h2,
h3 {
    font-family: var(--display);
    line-height: 1.1;
}

h1 {
    font-size: 2.75rem;
    font-weight: 700;
    margin: 0.5rem 0 0.25rem;
}

h2 {
    font-size: 1.6rem;
    font-weight: 600;
    margin: 0 0 1rem;
}

.lede {
    color: var(--muted);
    max-width: 62ch;
    margin: 0 0 1.75rem;
}

/* Each group of content: a flat white panel with an ink rule on top, no shadow */
section {
    background: var(--panel);
    border: 1px solid var(--line);
    border-top: 4px solid var(--ink);
    padding: 1.25rem 1.5rem 1.5rem;
    margin-bottom: 1.5rem;
}

/* A heading with controls on the same line (entries filters) */
.panel-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem 1.5rem;
    margin-bottom: 1rem;
}

.panel-head h2,
.panel-head .controls {
    margin: 0;
}

/* ---- Inputs ---- */

label {
    font-weight: 600;
    font-size: 0.95rem;
}

select,
input,
button {
    font: inherit;
}

select,
input {
    min-height: 2.5rem;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--line-strong);
    border-radius: 3px;
    background: #fff;
    color: var(--ink);
}

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

/* The row of labels and inputs above each chart; wraps onto a new line on narrow screens */
.controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
    margin-bottom: 1rem;
}

/* Form fields: label above input, as many columns as fit */
.fields {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
    gap: 0.9rem 1rem;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.field input,
.field select {
    width: 100%;
}

.field.wide {
    grid-column: 1 / -1;
}

.optional {
    font-weight: 400;
    color: var(--muted);
}

/* ---- Buttons ---- */

button {
    cursor: pointer;
}

.primary {
    font-family: var(--display);
    font-weight: 600;
    font-size: 1.2rem;
    background: var(--tape);
    color: var(--ink);
    border: 2px solid var(--ink);
    border-radius: 3px;
    padding: 0.45rem 1.4rem;
}

.primary:hover {
    background: var(--tape-deep);
}

.primary:disabled {
    opacity: 0.6;
    cursor: progress;
}

.quiet {
    background: transparent;
    color: var(--ink);
    border: 1px solid var(--line-strong);
    border-radius: 3px;
    padding: 0.25rem 0.75rem;
}

.quiet:hover {
    border-color: var(--ink);
}

.quiet.danger {
    color: var(--sector);
}

.quiet.danger:hover {
    border-color: var(--sector);
}

.actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
    margin-top: 1.25rem;
}

/* ---- Messages ---- */

#error {
    color: var(--sector);
    font-weight: 600;
}

/* Don't leave a blank gap under the heading when there's no error */
#error:empty {
    display: none;
}

.message {
    font-weight: 600;
    margin: 0;
}

.message.error {
    color: var(--sector);
}

/* A brief tape-yellow highlight when something was just saved */
.flash {
    animation: flash 1.4s ease-out;
}

@keyframes flash {
    from {
        background: var(--tape);
    }
    to {
        background: transparent;
    }
}

@media (prefers-reduced-motion: reduce) {
    .flash {
        animation: none;
    }
}

/* ---- Charts page ---- */

/* Chart.js sizes the canvas to its parent, so each chart gets its own box */
.chart {
    position: relative;
    width: 100%;
}

/* Plateau and correlation results */
.readout {
    font-weight: 600;
    margin-bottom: 0;
}

.hint {
    color: var(--muted);
    margin-top: 0;
}

/* ---- Log page ---- */

.log-grid {
    display: grid;
    gap: 1.5rem;
}

@media (min-width: 820px) {
    .log-grid {
        grid-template-columns: 1fr 1fr;
        align-items: start;
    }
}

.log-grid section {
    margin-bottom: 0;
}

/* What was logged in this visit, newest first: like an official's scoresheet */
.session {
    list-style: none;
    padding: 0;
    margin: 1.25rem 0 0;
    border-top: 2px solid var(--ink);
    font-variant-numeric: tabular-nums;
}

.session:empty {
    display: none;
}

.session li {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.4rem 0.25rem;
    border-bottom: 1px solid var(--line);
}

.session .id {
    color: var(--muted);
}

/* ---- Entries page ---- */

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
}

th {
    font-family: var(--display);
    font-weight: 600;
    font-size: 1.05rem;
    text-align: left;
    white-space: nowrap;
    border-bottom: 2px solid var(--ink);
    padding: 0.45rem 0.6rem;
}

td {
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

tbody tr:hover {
    background: #f1f2ef;
}

.num {
    text-align: right;
}

td.id,
td.notes {
    color: var(--muted);
}

td.notes {
    min-width: 12ch;
}

td.row-actions {
    text-align: right;
    white-space: nowrap;
}

/* Smaller buttons in rows so a long table stays compact */
td.row-actions button {
    font-size: 0.9rem;
    padding: 0.1rem 0.6rem;
}

td.row-actions button + button {
    margin-left: 0.4rem;
}

tr.empty td {
    color: var(--muted);
    text-align: center;
    padding: 1.75rem 0.6rem;
}

/* Edit dialogs */
dialog {
    width: min(34rem, calc(100vw - 2rem));
    border: none;
    border-top: 6px solid var(--tape);
    padding: 1.5rem;
    background: var(--panel);
    color: var(--ink);
}

dialog::backdrop {
    background: rgba(31, 38, 42, 0.55);
}

dialog h2 {
    margin-bottom: 1.25rem;
}

/* For screen readers only: text that names a column with no visible heading */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

@media (max-width: 560px) {
    main {
        padding: 1rem 1rem 2.5rem;
    }

    section {
        padding: 1rem 1rem 1.25rem;
    }

    h1 {
        font-size: 2.25rem;
    }
}

/* ---- Accounts (10.7) ---- */

/* .actions and other display rules would otherwise beat the hidden attribute */
[hidden] {
    display: none !important;
}

/* Who's logged in, at the right end of the tape */
nav .account {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    font-family: var(--display);
    font-weight: 600;
    font-size: 1.1rem;
}

nav .account .quiet {
    border-color: var(--ink);
    font-family: var(--body);
    font-size: 0.9rem;
}

/* Log in, sign up and the steps in between: one narrow column */
main.account-page {
    max-width: 30rem;
}

.account-page .field .hint {
    margin: 0.25rem 0 0;
}

/* A link styled as the main button, e.g. "Log in" after confirming an email */
a.primary {
    display: inline-block;
    text-decoration: none;
}

/* A coach's athlete picker, under the page heading */
.athlete-picker {
    margin: 0 0 1rem;
}

.working-on {
    background: var(--panel);
    border-left: 4px solid var(--tape);
    padding: 0.5rem 0.9rem;
    max-width: 62ch;
    margin: 0 0 1.5rem;
}

/* "Added or edited by Joey Edie" under an entry's notes */
.edited-by {
    display: block;
    color: var(--muted);
    font-size: 0.85rem;
    font-style: italic;
}

/* A page with no description under its heading (waiting, verify, reset) still needs a gap */
.account-page h1 + section {
    margin-top: 1rem;
}

/* Links in page content, in the focus blue rather than the browser's default */
main a:not(.primary) {
    color: var(--focus);
}

/* A link next to buttons in a table row (the squad page's "Entries") */
td.row-actions a {
    margin-right: 0.75rem;
}
