/* planameal global styles. Values come from PROJECT_UX.md "Look" and "Layout for every screen". */

/* Atkinson Hyperlegible was designed for low vision: letters like I/l/1 and O/0 can't be confused.
   Served locally (SOUL: no CDNs). swap shows text in the fallback font instead of a blank page while it loads. */
@font-face {
    font-family: "Atkinson Hyperlegible";
    src: url("../fonts/AtkinsonHyperlegible-Regular.woff2") format("woff2");
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: "Atkinson Hyperlegible";
    src: url("../fonts/AtkinsonHyperlegible-Bold.woff2") format("woff2");
    font-weight: 700;
    font-display: swap;
}

:root {
    /* Every color passes WCAG AA on white (text 4.5:1, icons and outlines 3:1),
       while staying as light and thin as compliance allows. */
    --bg: #ffffff;
    --text: #111111;  /* 18.9:1 */
    --link: #1d5a3c;  /* 8.1:1. Deep green: reads as a link without shouting */
    --soft: #555555;  /* 7.5:1. Secondary text stays readable, not faded */
    --line: #757575;  /* 4.6:1. Lines that mark a control (bar edge) must pass 3:1 */
    --rule: #e3e3e3;  /* Decorative dividers only, never the only cue for anything */

    --font: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
    --size-body: 17px;   /* Above the usual 16px: read at arm's length, often in a kitchen */
    --size-h1: 30px;
    --size-choice: 22px; /* Main choices are the biggest text on a screen: easy to see, find and push */
    --size-small: 15px;
    --size-bar: 13px;    /* Bar labels support their icons, so they can be small */

    --tap: 44px;     /* Minimum touch target (Apple HIG, WCAG 2.5.5) */
    --gutter: 12px;  /* One side margin everywhere so header, content and menu line up. Small: no wasted white space on a phone */
}

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

/* hidden must always win, even over display: flex/grid on a class (e.g. filtered search rows) */
[hidden] { display: none !important; }

/* Full-height column so the bottom bar sits at the bottom even on short pages */
html, body { height: 100%; }

body {
    margin: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font: var(--size-body)/1.45 var(--font);
}

/* Phone only. A big screen shows the page at iPhone 17 size (402 x 874, as in browser devtools), centered on gray.
   The body becomes the scroller, so the sticky bottom bar sticks to the phone's bottom edge, not the window's. */
@media (min-width: 500px) {
    :root { --phone-w: 402px; --phone-h: min(874px, 100dvh - 32px); }
    /* overflow on html stops body's overflow passing to the window, so the body itself scrolls */
    html { display: grid; place-items: center; overflow: hidden; background: #d0d0d0; }
    body { flex: none; width: var(--phone-w); height: var(--phone-h); overflow-y: auto; box-shadow: 0 0 0 1px #757575; }
    /* The menu sits in the browser's top layer, outside the body: give it the same box, centered the same way */
    dialog.user-menu { width: var(--phone-w); height: var(--phone-h); margin: auto; } /* dialog.: beats the later .user-menu rule */
}

h1 { margin: 0; font-size: var(--size-h1); line-height: 1.1; font-weight: 700; text-wrap: balance; }
p { margin: 0; }

/* Underlined, not color alone, so links are found without seeing color (WCAG 1.4.1).
   1px line with a 4px gap keeps it thin and clear of descenders. */
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 4px; }

/* Keyboard users must always see where they are */
a:focus-visible, button:focus-visible, input:focus-visible {
    outline: 2px solid var(--link);
    outline-offset: 2px;
}

/* Line icons at 1.5px: thin and light, but still 3:1 against white */
.icon {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* The icon is 24px but the tap area is 44px, so it's easy to hit */
.icon-btn {
    width: var(--tap);
    height: var(--tap);
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    background: none;
    color: var(--text);
    cursor: pointer;
}

/* Header: name left, user icon right. Nothing else, so the screen's content gets the attention */
.site-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* Right padding is smaller because the icon button carries its own 10px of tap area */
    padding: 8px 6px 2px var(--gutter);
    padding-top: max(8px, env(safe-area-inset-top));
    min-height: 54px; /* Same height with or without the user icon (logged out has none), so pages don't shift */
}
.site-head .name { font-size: 20px; font-weight: 700; color: var(--text); text-decoration: none; }

/* Column with one gap: heading, note and choices sit evenly without per-element margins */
main { flex: 1; padding: 22px var(--gutter) 24px; display: flex; flex-direction: column; gap: 18px; }

/* One line of context under a page heading, e.g. the group name */
.page-note { font-size: var(--size-small); color: var(--soft); margin-top: -10px; }

/* Main choices: big options that are easy to see, find and push, without wasted white space.
   Plain text links, no cards (PROJECT_UX.md 2): no box padding eating into the width. */
.choices { list-style: none; margin: 0; padding: 0; display: grid; gap: 22px; }
/* Block link: the whole row width is pushable, not just the words */
.choices a { display: block; font-size: var(--size-choice); font-weight: 700; }
/* 44px tall to tap (WCAG 2.5.5) without more white space: 7px padding grows the hit area, -7px margin keeps the spacing */
.choices a { padding-block: 7px; margin-block: -7px; }
/* Tight under its link so each choice reads as one unit */
.choices p { margin-top: 3px; font-size: var(--size-small); color: var(--soft); }
/* The decision: as big as a choice, but not a link */
.choices .pick { display: block; font-size: var(--size-choice); font-weight: 700; }

/* Text boxes: full width, 44px tall, outline at 4.6:1 so the box itself is visible (WCAG 1.4.11) */
.fields { display: grid; gap: 12px; }
.field { display: grid; gap: 4px; font-size: var(--size-small); color: var(--soft); }
.field-input {
    width: 100%;
    min-height: var(--tap);
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    font: var(--size-body) var(--font); /* 17px also stops iOS zooming in on focus */
}
.field-input::placeholder { color: var(--soft); }

/* Main action: the one filled shape on a page, pushed to the bottom where the thumb is.
   White on link green is 8.1:1. */
.btn {
    margin-top: auto;
    width: 100%;
    min-height: var(--tap);
    border: 0;
    border-radius: 6px;
    background: var(--link);
    color: #ffffff;
    font: 700 var(--size-body) var(--font);
    cursor: pointer;
}

/* People list: one row per person, name left, action right. Thin rules only separate rows. */
.people { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.people li { display: flex; justify-content: space-between; align-items: center; min-height: var(--tap); border-bottom: 1px solid var(--rule); }
/* Pad the Add link out to a full 44px target without making the row taller */
.people a { padding: 10px 0 10px 24px; }
/* QR code: centered and full width, so it scans easily from across a table */
.qr-box { display: grid; gap: 8px; justify-items: center; text-align: center; }
.qr { display: block; width: 100%; height: auto; aspect-ratio: 1; }
.qr-box p { font-size: var(--size-small); color: var(--soft); }

/* Added: same spot as Add, plain text, so the row doesn't jump */
.people .added { font-size: var(--size-small); font-weight: 700; color: var(--link); }

/* Bottom bar: Home, Talk, Chat on every screen. Talking or typing to the AI is always one tap away (S25). */
.bottom-bar {
    position: sticky;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* Equal thirds: each item is a wide, easy target */
    background: var(--bg);
    border-top: 1px solid var(--line);
    padding-bottom: max(6px, env(safe-area-inset-bottom)); /* Clear the phone's home indicator */
}
.bottom-bar a {
    display: grid;
    justify-items: center;
    min-height: var(--tap);
    padding: 5px 0 2px; /* Tight: the bar takes as little height from the content as possible */
    font-size: var(--size-bar);
    color: var(--soft);
    text-decoration: none;
}
/* AI actions in the link color: they're always the first-class option */
.bottom-bar .ai { color: var(--link); }
/* Current page: darker and underlined, so it isn't shown by color alone */
.bottom-bar a[aria-current="page"] { color: var(--text); }
.bottom-bar a[aria-current="page"] span { text-decoration: underline; text-underline-offset: 3px; }

/* User menu: full-screen <dialog> from the header user icon. Full screen leaves room for big targets
   and nothing behind it to tap by mistake. <dialog> gives focus trapping and Esc to close for free. */
.user-menu {
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    margin: 0;
    padding: max(8px, env(safe-area-inset-top)) 0 max(16px, env(safe-area-inset-bottom));
    border: 0;
    background: var(--bg);
    color: var(--text);
}
.user-menu[open] { display: flex; flex-direction: column; }
.user-menu .icon-btn { align-self: flex-end; margin-right: 6px; } /* Close sits where the user icon was */
.user-menu .who { padding: 4px var(--gutter) 18px; }
.user-menu .who b { display: block; font-size: 24px; }
.user-menu .who span { font-size: var(--size-small); color: var(--soft); }
.user-menu nav { display: grid; }
.user-menu nav a { min-height: var(--tap); padding: 12px var(--gutter); font-size: 20px; }
/* Log out pushed to the bottom, away from everyday items, so it isn't hit by accident */
.user-menu .log-out { margin-top: auto; display: grid; }
.user-menu .log-out button { min-height: var(--tap); padding: 12px var(--gutter); border: 0; background: none; color: var(--link); font: 20px var(--font); text-align: left; text-decoration: underline; cursor: pointer; }

/* A form wrapping a page's content: its children lay out as if the form weren't there, so .btn still sinks to the bottom */
.page-form { display: contents; }
/* Log in with Google or Apple: outlined, so the email button stays the one filled shape. Logos per their brand rules. */
.providers { display: grid; gap: 10px; }
.provider { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: var(--tap); border: 1px solid var(--line); border-radius: 6px; color: var(--text); font-weight: 700; text-decoration: none; }
.provider svg { width: 20px; height: 20px; flex: none; }
.form-error { color: #b00020; font-weight: 700; } /* 7.5:1 */

/* Done on a page that moves on: a link styled as the main button, centered like a real one */
a.btn, label.btn { display: grid; place-items: center; text-decoration: none; }

/* Group page sections (Meals, People): heading, its + action, then its list, close together */
.section { display: grid; gap: 8px; }
h2 { margin: 0; font-size: 20px; line-height: 1.2; }
/* "+" actions: one per section, big enough to find, smaller than a first-screen choice */
.add { display: block; padding: 10px 0; margin-block: -4px; font-size: 20px; font-weight: 700; } /* 44px to tap; the margin keeps the old spacing */
/* List rows: link on the left takes the full width so it's easy to hit; one short fact on the right */
.rows a { flex: 1; padding: 10px 0; }
.rows span { font-size: var(--size-small); color: var(--soft); text-align: right; }
.more { display: inline-block; padding-block: 12px; margin-block: -12px; font-size: var(--size-small); } /* 44px to tap, same spacing */

/* Allergies: outline only, no color. It must read as important to everyone, not as an error */
/* Status: same outline, for a one-time confirmation like "Invite sent" */
.allergy-box, .status { padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; font-size: var(--size-small); }

/* Chats: messages sit at the bottom, near the message box, like any chat app */
.msgs { flex: 1; display: grid; gap: 14px; align-content: end; }
.msgs b { display: block; font-size: var(--size-small); }
.msg-actions { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 2px; }
.compose { display: flex; gap: 6px; align-items: center; }
.icon-btn.ai { color: var(--link); }

/* Talk: replaces the ask box while listening, so it's obvious the mic is on and how to stop */
.listening { display: grid; gap: 10px; padding-top: 12px; border-top: 1px solid var(--rule); }
.listening .btn { margin-top: 0; }

/* Rating rows (PROJECT_UX.md 5): name on its own line, then the choices in one row of equal 44px buttons,
   so a whole list can be rated with one thumb. Allergic comes first because it matters most. */
.rate { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.rate li { display: grid; gap: 6px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg a { display: grid; place-items: center; min-height: var(--tap); padding: 0 2px; font-size: var(--size-small); text-align: center; text-decoration: none; }
.seg a + a { border-left: 1px solid var(--line); }
/* Chosen: filled, not just recolored, so it shows without seeing color */
.seg a[aria-pressed="true"], .seg a[aria-current] { background: var(--link); color: #ffffff; font-weight: 700; }
/* Allergy details open under the row, in the allergy box */
.rate .allergy-box { display: grid; gap: 6px; }
.rate .allergy-box .seg { grid-auto-flow: row; }
.rate .allergy-box .seg a + a { border-left: 0; border-top: 1px solid var(--line); }

/* Grocery list: the whole row is the checkbox, 44px tall, so it can be ticked one-handed in a store */
.checks { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.checks label { display: flex; align-items: center; gap: 12px; min-height: var(--tap); border-bottom: 1px solid var(--rule); }
.checks input { width: 22px; height: 22px; margin: 0; accent-color: var(--link); }
/* Ticked: struck through and softened, but still readable in case it was a mistake */
.checks label:has(input:checked) { color: var(--soft); text-decoration: line-through; }

/* Settings: one choice per group, the whole row is the radio button, 44px tall. A second line says what it's for. */
.picks { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.picks label { display: flex; align-items: center; gap: 12px; min-height: var(--tap); padding: 6px 0; border-bottom: 1px solid var(--rule); }
.picks input { flex: none; width: 22px; height: 22px; margin: 0; accent-color: var(--link); }
.picks small { display: block; font-size: var(--size-small); color: var(--soft); }
.picks label:has(input:disabled) { color: var(--soft); }

/* Not built yet: what the page will do, in the middle of the page, marked so no one mistakes it for done */
.on-hold { flex: 1; display: grid; place-content: center; gap: 10px; text-align: center; }
.on-hold b { justify-self: center; padding: 2px 10px; border: 1px solid var(--line); border-radius: 6px; font-size: var(--size-small); }

/* Picture survey (S29): two photos a row, big enough to judge food by; the name under each. Picked: thick outline. */
.pics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; } /* minmax(0): a long name wraps instead of widening its column */
.pics a { display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; gap: 4px; padding: 4px; border: 3px solid transparent; border-radius: 8px; font-weight: 700; text-decoration: none; }
.pics a[aria-pressed="true"] { border-color: var(--link); }
.pic { display: grid; place-items: center; aspect-ratio: 4 / 3; border-radius: 6px; background: var(--rule); color: var(--soft); font-size: var(--size-small); font-weight: 400; }

/* Talk examples: smaller than a main choice, since they're full sentences, but still bold, big targets */
.choices a.say { font-size: 19px; padding-block: 9px; margin-block: -9px; } /* Smaller text, so more padding to stay 44px */

/* A choice someone in the group can't eat: still listed so nobody wonders where it went, but struck and not a link */
.choices .pick.out { color: var(--soft); text-decoration: line-through; }
/* What a dish means for each person's allergies: on its own line, in text color, so a "check first" isn't skimmed past */
.choices p.fit { color: var(--text); }
/* "Check first" waiting on someone: the question, then its answers as 44px buttons */
.allergy-box.check, .allergy-box.where { display: grid; gap: 8px; }
/* Photos keep the same warning as the words, under the name */
.pics small { font-size: var(--size-small); font-weight: 400; color: var(--text); }

/* Talk (PROJECT_UX.md 7.2): things to ask, under the conversation, until you ask one */
.asks { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.asks a.say { display: block; padding-block: 10px; font-size: 19px; font-weight: 700; }
.compose .field-input { flex: 1; }
.compose .btn.send { width: auto; margin-top: 0; padding-inline: 16px; }
/* Bot actions: each one a 44px target, since they're how the conversation moves on */
.msg-actions a { display: inline-block; padding-block: 11px; margin-block: -8px; }

/* Ingredient rating: "Not in it" fixes a wrong lookup. Smaller than the ratings, still 44px tall. */
.rate .not-in { justify-self: start; padding-block: 12px; margin-block: -10px; font-size: var(--size-small); }
