/* ============================================================================
   assets/css/style.css
   ----------------------------------------------------------------------------
   The one stylesheet for the whole app. Warm scrapbook / yearbook look.
   Built for a 375px-wide phone first, then it simply centers on bigger screens.

   COLORS: don't change colors here. They come from config.php -> themes and
   are printed as CSS variables (--bg, --card, --accent, --accent2, --text)
   at the top of every page by includes/layout.php.

   Sizes: every button and form box is at least 44px tall, so it's easy to tap.
   ============================================================================ */

/* ---------- Basics ---------- */

* { box-sizing: border-box; }

:root {
    --radius: 14px;
    --tap: 48px;                                   /* Height of buttons and inputs (44px minimum) */
    --shadow: 0 2px 6px rgba(0, 0, 0, .08), 0 8px 20px rgba(0, 0, 0, .05);
    --error: #c0392b;
    --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-hand: "Caveat", "Comic Sans MS", "Bradley Hand", cursive;   /* Handwritten headings */
}

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font: 17px/1.5 var(--font-body);               /* 16px+ stops iPhones zooming into inputs */
    color: var(--text);
    background-color: var(--bg);
    /* Faint dotted paper, like a scrapbook page */
    background-image: radial-gradient(rgba(0, 0, 0, .06) 1px, transparent 1px);
    background-size: 18px 18px;
    min-height: 100vh;
}

h1, h2, h3 {
    font-family: var(--font-hand);
    font-weight: 700;
    line-height: 1.1;
    margin: 0 0 8px;
}
h1 { font-size: 40px; }
h2 { font-size: 30px; }

p { margin: 0 0 12px; }
a { color: var(--accent); }

.lead  { font-size: 18px; }
.small { font-size: 14px; }
.muted { opacity: .7; }

/* ---------- Page frame ---------- */

.topbar {
    display: flex;
    align-items: center;
    min-height: 56px;
    padding: 0 16px;
    padding-top: env(safe-area-inset-top);
}

.brand {
    font-family: var(--font-hand);
    font-size: 30px;
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
}

.page {
    max-width: 480px;
    margin: 0 auto;
    padding: 8px 16px 40px;
    padding-bottom: calc(40px + env(safe-area-inset-bottom));
}

/* ---------- Cards (paper with a strip of tape) ---------- */

.card {
    position: relative;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px 16px;
    margin: 0 0 16px;
    border: 0;
    min-width: 0;                                  /* Lets fieldset cards shrink on small phones */
}

/* A slightly crooked card with tape on top, like it was stuck in by hand */
.card-tilt { transform: rotate(-1deg); margin-top: 22px; }
.card-tilt::before {
    content: "";
    position: absolute;
    top: -12px;
    left: 50%;
    width: 96px;
    height: 24px;
    margin-left: -48px;
    background: var(--accent2);
    opacity: .55;
    transform: rotate(2deg);
    border-radius: 2px;
}

/* Fieldset cards: the legend sits inside the card as a handwritten title */
fieldset.card > legend {
    float: left;                                   /* Keeps the legend inside the card */
    width: 100%;
    padding: 0;
    margin-bottom: 8px;
    font-family: var(--font-hand);
    font-size: 26px;
    font-weight: 700;
    line-height: 1.2;
}
fieldset.card > legend + * { clear: both; }

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

.button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    min-height: var(--tap);
    padding: 10px 20px;
    margin: 0 0 12px;
    border: 2px solid var(--accent);
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font: 600 18px/1.2 var(--font-body);
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.button:active { transform: translateY(1px); }
.button:focus-visible, input:focus-visible, select:focus-visible, .choice input:focus-visible + span {
    outline: 3px solid var(--accent2);
    outline-offset: 2px;
}

.button-secondary { background: transparent; color: var(--accent); }
.button-quiet     { background: transparent; color: var(--text); border-color: transparent; text-decoration: underline; }
.button-small     { min-height: 44px; font-size: 16px; width: auto; margin: 4px 0 0 auto; }

.button-google { background: #fff; color: #3c4043; border-color: #dadce0; }
.google-g {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #4285f4;
    color: #fff;
    font-weight: 700;
}

/* Invisible default button (Enter key = Next). Not display:none, so browsers still use it. */
.enter-default { position: absolute; width: 1px; height: 1px; padding: 0; border: 0; opacity: 0; overflow: hidden; }

.back-link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
}

/* ---------- Forms ---------- */

.form { margin-bottom: 16px; }

.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-weight: 600; margin-bottom: 6px; }
.field small, .field > span small { display: block; font-weight: 400; opacity: .7; margin-top: 4px; }
.field > span small { display: inline; }

input[type="text"], input[type="tel"], input[type="date"], input[type="email"], select {
    display: block;
    width: 100%;
    min-height: var(--tap);
    padding: 10px 12px;
    border: 2px solid rgba(0, 0, 0, .15);
    border-radius: 10px;
    background: #fff;
    color: #222;
    font: 17px/1.3 var(--font-body);
    -webkit-appearance: none;
    appearance: none;
}
input[type="date"] { min-width: 0; }
select {
    /* A small arrow, since appearance:none removes the phone's own one */
    background-image: linear-gradient(45deg, transparent 50%, #777 50%), linear-gradient(135deg, #777 50%, transparent 50%);
    background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%;
    background-size: 6px 6px;
    background-repeat: no-repeat;
    padding-right: 36px;
}
input:focus, select:focus { border-color: var(--accent); }

.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; min-width: 0; }

.has-error input, .has-error select, .field.has-error input { border-color: var(--error); }
.error { display: block; color: var(--error); font-style: normal; font-size: 15px; margin: 4px 0 8px; }

.notice {
    background: var(--card);
    border-left: 5px solid var(--accent2);
    border-radius: 8px;
    padding: 12px 14px;
    box-shadow: var(--shadow);
}
.notice-error { border-left-color: var(--error); }

/* ---------- Tap-button choices (check questions) ---------- */

.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.choice span {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 8px 16px;
    border: 2px solid rgba(0, 0, 0, .15);
    border-radius: 999px;
    background: #fff;
    color: #222;
    cursor: pointer;
}
.choice input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.choice-skip span { border-style: dashed; opacity: .8; }
.choice-skip input:checked + span { background: var(--bg); border-color: rgba(0, 0, 0, .3); color: var(--text); }  /* Skipping isn't an answer, so it stays quiet */

.question.is-answered { border-left: 5px solid var(--accent2); }

/* ---------- On/off toggle ---------- */

.toggle { display: flex; align-items: center; gap: 14px; min-height: var(--tap); margin-bottom: 8px; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle-switch {
    flex: none;
    position: relative;
    width: 56px;
    height: 32px;
    border-radius: 999px;
    background: rgba(0, 0, 0, .2);
    transition: background .2s;
}
.toggle-switch::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
    transition: left .2s;
}
.toggle input:checked + .toggle-switch { background: var(--accent); }
.toggle input:checked + .toggle-switch::after { left: 27px; }
.toggle input:focus-visible + .toggle-switch { outline: 3px solid var(--accent2); outline-offset: 2px; }
.toggle-text { font-weight: 600; }

/* ---------- Progress bar ---------- */

.progress {
    height: 12px;
    border-radius: 999px;
    background: rgba(0, 0, 0, .08);
    overflow: hidden;
    margin: 8px 0 4px;
}
.progress-fill {
    height: 100%;
    border-radius: 999px;
    background: repeating-linear-gradient(-45deg, var(--accent), var(--accent) 8px, var(--accent2) 8px, var(--accent2) 16px);
}
.progress-label { font-size: 14px; opacity: .7; margin-bottom: 16px; }

/* ---------- Welcome screen ---------- */

.welcome { text-align: center; padding-top: 24px; }
.welcome h1 { font-size: 52px; }
.welcome .lead { margin-bottom: 28px; }
.tagline { font-family: var(--font-hand); font-size: 28px; color: var(--accent); margin-top: 24px; }

/* ---------- Tutorial ---------- */

.tutorial-card { text-align: center; padding: 32px 20px; }
.tutorial-count { font-size: 14px; opacity: .6; }
.dots { display: flex; justify-content: center; gap: 8px; margin-top: 16px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: rgba(0, 0, 0, .15); }
.dot.is-on { background: var(--accent); }

/* ---------- Tags (chapters, level) ---------- */

.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag {
    display: inline-block;
    padding: 4px 12px;
    margin: 0 4px 4px 0;
    border-radius: 999px;
    background: var(--bg);
    border: 1px dashed var(--accent);
    font-size: 15px;
}
.tag-level { background: var(--accent); color: #fff; border-style: solid; }
.next-step { font-weight: 600; }
