/* foltzday board styles.
 *
 * Three constraints drive everything here, and they're family constraints,
 * not taste:
 *
 * 1. SIZE-ADAPTIVE. The same page is read on an old wall tablet from six
 *    feet away and on a phone held at arm's length. Type and spacing scale
 *    with the viewport via clamp() rather than snapping at breakpoints, so
 *    there's no screen size where the board is briefly unusable.
 * 2. LOW STIMULATION. Muted palette, no animation, no bright white. A board
 *    that lives on a kitchen wall is in someone's peripheral vision all day,
 *    and a migraine-prone adult has to be able to walk past it.
 * 3. BIG, FORGIVING TARGETS. Nothing tappable is under 88px, nothing needs
 *    a drag or a long-press, and nothing needs a firm press. Hypermobile
 *    hands tire fast; precision tapping is a tax we don't charge.
 */

:root {
    color-scheme: dark light;

    /* Muted, low-contrast-on-purpose. Not pure black, not pure white. */
    --bg: #14161a;
    --surface: #1c1f25;
    --surface-2: #23272f;
    --rule: #333944;
    --ink: #e4e2dd;
    --ink-dim: #9aa0ab;
    --ink-faint: #6b7280;
    --accent: #c8783c;

    /* Fluid type. Small end = phone, large end = wall tablet across a room. */
    --step-0: clamp(0.95rem, 0.85rem + 0.5vw, 1.15rem);
    --step-1: clamp(1.15rem, 1rem + 0.8vw, 1.5rem);
    --step-2: clamp(1.5rem, 1.2rem + 1.6vw, 2.4rem);
    --step-3: clamp(2rem, 1.5rem + 2.8vw, 3.6rem);

    --gap: clamp(0.75rem, 0.5rem + 1vw, 1.5rem);
    --radius: 10px;
    --tap: 88px; /* minimum touch target, every axis */
}

@media (prefers-color-scheme: light) {
    :root {
        --bg: #f4f2ee;
        --surface: #ffffff;
        --surface-2: #eae7e1;
        --rule: #d6d2ca;
        --ink: #23272f;
        --ink-dim: #5a6270;
        --ink-faint: #8b93a0;
    }
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: var(--gap);
    background: var(--bg);
    color: var(--ink);
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: var(--step-0);
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
}

/* No motion anywhere. This is the default, not a preference override —
 * movement in peripheral vision is a migraine trigger in this house. */
* {
    animation: none !important;
    transition: none !important;
}

h1 {
    font-size: var(--step-3);
    margin: 0 0 var(--gap);
    font-weight: 600;
    letter-spacing: -0.02em;
}

h2 {
    font-size: var(--step-2);
    margin: 0 0 calc(var(--gap) * 0.5);
    font-weight: 600;
}

p {
    margin: 0 0 var(--gap);
    max-width: 60ch;
}

a {
    color: var(--accent);
}

.muted {
    color: var(--ink-dim);
}

.faint {
    color: var(--ink-faint);
    font-size: 0.9em;
}

/* --- layout --- */

.wrap {
    max-width: 1400px;
    margin: 0 auto;
}

.topbar {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--gap);
    margin-bottom: var(--gap);
}

.card {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: var(--gap);
    margin-bottom: var(--gap);
}

/* --- tappable tiles ---
 *
 * The board's cards used to be inert markup that looked exactly like
 * something you could touch. On a wall tablet that reads as a broken app,
 * because touching the thing you want to change is the first thing anyone
 * tries. These rules make "it drills in" visible before the tap, not after.
 *
 * :active rather than :hover — the wall board has no cursor, and a hover
 * style on a touchscreen sticks after the finger leaves.
 *
 * Feedback is a flat colour change ONLY. No transition, no transform: this
 * file's opening rule kills motion everywhere on purpose, because movement in
 * peripheral vision is a migraine trigger in this house. A tappable tile is
 * not worth breaking that for. */
.card-link,
.occ-link,
.person-link {
    display: block;
    color: inherit;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

.card-link:active,
.occ-link:active,
.person-link:active {
    background: var(--surface-2);
}

/* The chevron is the affordance doing the real work — it says "there is more
 * behind this" without any words to read from across a kitchen. */
.card-go {
    float: right;
    opacity: 0.45;
    font-weight: 400;
}

/* .occ already provides the flex row, the 88px target, and the person
 * stripe. The anchor only needs to stop looking like a link. */
.occ-link .card-go {
    float: none;
    margin-left: auto;
}

.person-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-radius: var(--radius);
}

/* The board's own tab bar. It sits under the cards rather than at the top:
 * the board's job is to show the day, and navigation is the rare case. */
.board-tabs {
    margin-top: var(--gap);
}

/* --- people --- */

/* auto-fit + minmax means one row on a wall tablet and a clean wrap on a
 * phone, with no breakpoint in between. */
.people {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
    gap: var(--gap);
    list-style: none;
    margin: 0;
    padding: 0;
}

.person {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: var(--tap);
    padding: var(--gap);
    background: var(--surface-2);
    border: 2px solid var(--person-color, var(--rule));
    border-radius: var(--radius);
    text-align: center;
}

/* The avatar carries the identity, the name is the caption. That ordering is
 * the point: both kids are pre-readers, so the glyph has to do the work. */
.person-avatar {
    font-size: var(--step-3);
    line-height: 1;
}

.person-name {
    font-size: var(--step-1);
    font-weight: 600;
}

.person-kind {
    font-size: 0.85em;
    color: var(--ink-dim);
}

/* --- view tabs --- */

.viewtabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: var(--gap);
}

.viewtab {
    display: inline-flex;
    align-items: center;
    min-height: 56px;
    padding: 0.5rem 1.1rem;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    color: var(--ink-dim);
    text-decoration: none;
    font-size: var(--step-0);
}

.viewtab.on {
    background: var(--surface-2);
    border-color: var(--accent);
    color: var(--ink);
    font-weight: 600;
}

.btn-icon {
    min-width: 56px;
    font-size: var(--step-2);
    line-height: 1;
}

/* --- occurrences --- */

.occ-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* The whole row is the target, not a small link inside it. Nothing here
 * needs precision tapping. */
.occ {
    display: flex;
    align-items: center;
    gap: var(--gap);
    min-height: var(--tap);
    padding: 0.7rem var(--gap);
    background: var(--surface-2);
    border-left: 6px solid var(--person-color, var(--rule));
    border-radius: var(--radius);
}

.occ-avatar {
    font-size: var(--step-2);
    line-height: 1;
    flex: 0 0 auto;
}

.occ-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.occ-title {
    font-size: var(--step-1);
    font-weight: 600;
    overflow-wrap: anywhere;
}

.occ-meta {
    color: var(--ink-dim);
    font-size: 0.9em;
}

.occ-list.compact .occ {
    min-height: 0;
    padding: 0.3rem 0.5rem;
    gap: 0.4rem;
    border-left-width: 4px;
}

.occ-list.compact .occ-avatar {
    font-size: var(--step-0);
}

.occ-list.compact .occ-title {
    font-size: 0.9em;
    font-weight: 500;
}

.occ-list.compact .occ-meta {
    font-size: 0.8em;
}

.big {
    font-size: var(--step-1);
}

/* --- week + month grid --- */

.grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(7.5rem, 1fr));
    gap: 2px;
    background: var(--rule);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    overflow: hidden;
    /* Wide on a phone by nature — the parent .scroll-x pans it rather than
     * cramming seven columns into 360px and making them all unreadable. */
    min-width: 52rem;
}

.grid-head {
    background: var(--surface-2);
    padding: 0.5rem;
    text-align: center;
    color: var(--ink-dim);
    font-size: 0.9em;
    font-weight: 600;
}

.grid-cell {
    background: var(--surface);
    padding: 0.4rem;
    min-height: 7rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.grid-week .grid-cell {
    min-height: 14rem;
}

.grid-cell.out {
    background: var(--bg);
}

.grid-cell.out .grid-date {
    color: var(--ink-faint);
}

.grid-cell.today {
    box-shadow: inset 0 0 0 2px var(--accent);
}

.grid-date {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    min-height: 2rem;
    align-self: flex-start;
    color: var(--ink-dim);
    text-decoration: none;
    font-weight: 600;
}

.grid-cell.today .grid-date {
    color: var(--accent);
}

/* --- routines --- */

.routine {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-left: 6px solid var(--person-color, var(--rule));
    border-radius: var(--radius);
    padding: var(--gap);
    margin-bottom: var(--gap);
}

/* A finished routine recedes rather than disappearing. Vanishing would erase
 * the evidence of what she did, which is half the reward. */
.routine.done {
    opacity: 0.72;
}

.routine-head {
    display: flex;
    align-items: center;
    gap: var(--gap);
    margin-bottom: 0.6rem;
}

.routine-avatar {
    font-size: var(--step-2);
    line-height: 1;
}

.routine-heading {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1 1 auto;
}

.routine-title {
    font-size: var(--step-1);
    font-weight: 600;
}

.routine-who {
    color: var(--ink-dim);
    font-size: 0.9em;
}

.routine-count {
    font-size: var(--step-1);
    color: var(--ink-dim);
    font-variant-numeric: tabular-nums;
}

.bar {
    height: 10px;
    background: var(--surface-2);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 0.8rem;
}

.bar-fill {
    height: 100%;
    background: var(--person-color, var(--accent));
}

.steps {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(15rem, 100%), 1fr));
    gap: 0.6rem;
}

/* The entire step is the button. Oversized, low-force, no drag, no
 * long-press — hypermobile hands tire fast and precision tapping is a tax
 * this app doesn't charge. */
.step {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    width: 100%;
    min-height: var(--tap);
    padding: 0.6rem 0.9rem;
    background: var(--surface-2);
    border: 2px solid var(--rule);
    border-radius: var(--radius);
    color: var(--ink);
    font-family: inherit;
    font-size: var(--step-1);
    text-align: left;
    cursor: pointer;
}

.step:disabled {
    cursor: default;
    opacity: 0.6;
}

.step-done {
    border-color: var(--person-color, var(--accent));
    background: var(--surface);
}

/* Struck through AND checked: the state is legible without relying on
 * color, which matters for two colorblind-adjacent adults and a kid who
 * can't read the label yet. */
.step-done .step-label {
    text-decoration: line-through;
    color: var(--ink-dim);
}

.step-icon {
    font-size: var(--step-2);
    line-height: 1;
    flex: 0 0 auto;
}

.step-label {
    flex: 1 1 auto;
    overflow-wrap: anywhere;
}

.step-check {
    font-size: var(--step-1);
    color: var(--person-color, var(--accent));
    flex: 0 0 auto;
    min-width: 1.2em;
    text-align: right;
}

.star-count {
    font-size: var(--step-1);
    font-variant-numeric: tabular-nums;
}

.redeem {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

.redeem input {
    width: 5rem;
    min-height: 56px;
    padding: 0.4rem;
    background: var(--surface-2);
    color: var(--ink);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    font-size: var(--step-0);
    font-family: inherit;
    text-align: center;
}

.step-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
}

.step-row input[type="text"] {
    min-height: 56px;
}

.step-row .icon-field {
    width: 5rem;
    text-align: center;
}

/* --- board mode (the always-on wall screen) --- */

/* The board is read from across a room, so it gets a size bump over the
 * phone views. Still fluid — the same page has to work on the tablet, on a
 * phone, and on a laptop. */
body.board {
    --step-0: clamp(1rem, 0.9rem + 0.6vw, 1.35rem);
    --step-1: clamp(1.25rem, 1.05rem + 1vw, 1.8rem);
    --step-2: clamp(1.7rem, 1.3rem + 2vw, 2.9rem);
    --step-3: clamp(2.2rem, 1.6rem + 3.4vw, 4.2rem);
    --tap: 96px;
}

/* Quiet mode: the "bad day" switch. Lower contrast, less to look at.
 * On a migraine day a board showing the full plan is a board that gets
 * ignored, so this one drops finished routines and the star tiles and
 * leaves only what's still to do. */
body.board.quiet {
    --ink: #b9b6b0;
    --accent: #9a7550;
}

@media (prefers-color-scheme: light) {
    body.board.quiet {
        --ink: #4a505c;
    }
}

.board-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--gap);
    margin-bottom: var(--gap);
}

/* The sleep veil. A web page can't switch a tablet's backlight off — that's
 * an OS setting — so it goes fully black and stops being something to look
 * at. On the kitchen wall at 10pm that's most of the benefit. */
.veil {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.veil[hidden] {
    display: none;
}

/* Barely visible on purpose: enough to tell a groggy adult the screen isn't
 * broken, not enough to light up a dark kitchen. */
.veil-hint {
    color: #1c1c1c;
    font-size: var(--step-0);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

/* --- weather --- */

.weather {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
}

.weather-icon {
    font-size: var(--step-2);
    line-height: 1;
}

.weather-temp {
    font-size: var(--step-2);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.weather-range {
    color: var(--ink-dim);
    font-variant-numeric: tabular-nums;
}

/* An unplanned meal slot is visible but recessed — a gap you can see is a
 * gap somebody fills. */
.occ-empty {
    opacity: 0.6;
    border-left-style: dashed;
}

.add-item {
    display: flex;
    gap: 0.5rem;
    margin-top: var(--gap);
}

.add-item input {
    flex: 1 1 auto;
}

/* --- who chips --- */

.who {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.who-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 56px;
    padding: 0.4rem 0.9rem;
    background: var(--surface-2);
    border: 2px solid var(--person-color, var(--rule));
    border-radius: var(--radius);
    color: var(--ink);
    cursor: pointer;
}

.who-chip input {
    width: 1.4rem;
    height: 1.4rem;
    accent-color: var(--accent);
}

details > summary {
    list-style: none;
    user-select: none;
}

details > summary::-webkit-details-marker {
    display: none;
}

/* --- forms + buttons --- */

label {
    display: block;
    margin-bottom: 0.35rem;
    color: var(--ink-dim);
}

input[type="text"],
input[type="password"] {
    width: 100%;
    max-width: 32rem;
    min-height: 56px;
    padding: 0.6rem 0.8rem;
    background: var(--surface-2);
    color: var(--ink);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    font-size: var(--step-1);
    font-family: inherit;
}

input:focus-visible,
.btn:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 56px;
    min-width: 10rem;
    padding: 0.7rem 1.4rem;
    background: var(--surface-2);
    color: var(--ink);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    font-size: var(--step-1);
    font-family: inherit;
    text-decoration: none;
    cursor: pointer;
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #14161a;
    font-weight: 600;
}

.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--gap);
    align-items: center;
}

/* --- misc --- */

.notice {
    padding: var(--gap);
    border-left: 4px solid var(--accent);
    background: var(--surface-2);
    border-radius: 0 var(--radius) var(--radius) 0;
    margin-bottom: var(--gap);
}

.error {
    border-left-color: #c85c5c;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    text-align: left;
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid var(--rule);
}

th {
    color: var(--ink-dim);
    font-weight: 600;
    font-size: 0.9em;
}

/* Wide content scrolls inside its own box; the page body never scrolls
 * sideways on a phone. */
.scroll-x {
    overflow-x: auto;
}

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    background: var(--surface-2);
    padding: 0.15em 0.4em;
    border-radius: 4px;
    font-size: 0.9em;
}

/* --- cycle --- */

/* An elevated-risk day gets a warm left edge rather than a red alarm. This
 * is information for planning the week, not a warning about a condition. */
.cycle-elevated {
    border-left: 4px solid #c2568c;
}

/* Simple vertical form stack; the cycle form is the only one that needs it. */
.stack {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.stack label {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}
