/* =========================================================================
   School Portal — design system
   -------------------------------------------------------------------------
   Written by hand rather than compiled from a utility framework. The brief
   allows a purged utility build, but that needs a Node toolchain in the
   pipeline to stay honest; plain CSS keeps the whole shipped stylesheet
   readable and removes a build step from a project that already can't run
   Composer on the host. If the school later wants Tailwind, this file is the
   spec to port.

   Fonts are local files in ../fonts/. Nothing here reaches the network.
   ========================================================================= */

@font-face {
    font-family: 'Inter';
    src: url('../fonts/InterVariable.woff2') format('woff2-variations');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'DM Serif Display';
    src: url('../fonts/DMSerifDisplay-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

:root {
    /* Ink on cool paper, with a single saturated blue doing the work and
       marigold reserved for "this needs a person's attention". */
    --ink:        #14213D;
    --ink-soft:   #4A5670;
    --paper:      #F2F4F8;
    --surface:    #FFFFFF;
    --line:       #14213D;
    --primary:    #2F5AE0;
    --primary-dk: #1E3EA8;
    --accent:     #F2B705;
    --danger:     #C8452C;
    --success:    #1F7A5C;

    --radius:     12px;
    --border:     2.5px;
    /* The signature: hard offset shadows, no blur. Panels read like stacked
       index cards on a front-desk counter rather than floating glass. */
    --lift:       4px 4px 0 var(--ink);
    --lift-sm:    3px 3px 0 var(--ink);

    --space:      1rem;
    --maxw:       68rem;
}

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

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

body {
    margin: 0;
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-size: 1rem;
    line-height: 1.55;
    color: var(--ink);
    background: var(--paper);
    /* Room for the fixed bottom tab bar on phones. */
    padding-bottom: env(safe-area-inset-bottom);
}

h1, h2, h3 {
    font-family: 'DM Serif Display', Georgia, 'Times New Roman', serif;
    font-weight: 400;
    line-height: 1.15;
    letter-spacing: -0.01em;
    margin: 0 0 0.5rem;
}

h1 { font-size: clamp(1.75rem, 5vw, 2.5rem); }
h2 { font-size: clamp(1.35rem, 3.5vw, 1.75rem); }
h3 { font-size: 1.15rem; }

p { margin: 0 0 1rem; }
a { color: var(--primary-dk); text-decoration-thickness: 2px; text-underline-offset: 2px; }
a:hover { color: var(--ink); }

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

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

.shell { max-width: var(--maxw); margin: 0 auto; padding: 1.25rem 1rem 6rem; }

@media (min-width: 48rem) {
    .shell { padding-bottom: 3rem; }
}

.stack > * + * { margin-top: 1rem; }
.row { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center; }
.row-end { justify-content: flex-end; }
.grow { flex: 1 1 auto; }
.muted { color: var(--ink-soft); }
.small { font-size: 0.875rem; }
.mono { font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------- head --- */

.masthead {
    background: var(--surface);
    border-bottom: var(--border) solid var(--line);
}

.masthead__inner {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.wordmark {
    font-family: 'DM Serif Display', Georgia, serif;
    font-size: 1.35rem;
    color: var(--ink);
    text-decoration: none;
    white-space: nowrap;
}

.wordmark span { color: var(--primary); }

/* Desktop nav. On phones this is replaced by the bottom tab bar below. */
.topnav { display: none; gap: 0.25rem; margin-left: auto; }

@media (min-width: 48rem) {
    .topnav { display: flex; }
}

.topnav a {
    padding: 0.4rem 0.7rem;
    border-radius: 8px;
    font-weight: 550;
    font-size: 0.9rem;
    text-decoration: none;
    color: var(--ink-soft);
}

.topnav a[aria-current='page'] {
    background: var(--ink);
    color: #fff;
}

/* --------------------------------------------------- bottom tab bar ----- */

.tabbar {
    position: fixed;
    inset: auto 0 0 0;
    display: flex;
    background: var(--surface);
    border-top: var(--border) solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 20;
}

@media (min-width: 48rem) { .tabbar { display: none; } }

.tabbar a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 0.5rem 0.25rem 0.6rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--ink-soft);
    text-decoration: none;
}

.tabbar a[aria-current='page'] { color: var(--primary-dk); }
.tabbar .tabbar__glyph { font-size: 1.15rem; line-height: 1; }

/* --------------------------------------------------------------- card --- */

.card {
    background: var(--surface);
    border: var(--border) solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--lift);
    padding: 1.25rem;
}

.card + .card { margin-top: 1.25rem; }
.card__head { display: flex; align-items: baseline; gap: 0.75rem; margin-bottom: 0.75rem; }
.card__head h2, .card__head h3 { margin: 0; }

.card--flat { box-shadow: none; }
.card--attention { border-color: var(--accent); box-shadow: 4px 4px 0 var(--accent); }

/* -------------------------------------------------------------- badge --- */

.badge {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border: 2px solid var(--line);
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 650;
    letter-spacing: 0.01em;
    background: var(--surface);
}

.badge--pending { background: var(--accent); }
.badge--ok      { background: var(--success); color: #fff; border-color: var(--success); }
.badge--danger  { background: var(--danger);  color: #fff; border-color: var(--danger); }

/* Class icon fallback: a plain colored dot. */
.dot {
    display: inline-block;
    width: 0.9rem;
    height: 0.9rem;
    border-radius: 50%;
    border: 2px solid var(--line);
    vertical-align: -1px;
}

/* --------------------------------------------------------------- form --- */

.field { margin-bottom: 1rem; }

.field label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.3rem;
}

.field .hint { font-size: 0.8rem; color: var(--ink-soft); margin: 0.25rem 0 0; }

input[type='text'], input[type='email'], input[type='password'],
input[type='search'], input[type='date'], select, textarea {
    width: 100%;
    font: inherit;
    color: inherit;
    padding: 0.6rem 0.7rem;
    background: var(--surface);
    border: var(--border) solid var(--line);
    border-radius: 10px;
}

input:disabled, select:disabled { background: #E9ECF2; color: var(--ink-soft); }

textarea { min-height: 6rem; resize: vertical; }

.field--error input, .field--error select { border-color: var(--danger); }

.error-text {
    color: var(--danger);
    font-size: 0.85rem;
    font-weight: 600;
    margin: 0.3rem 0 0;
}

fieldset {
    border: var(--border) solid var(--line);
    border-radius: var(--radius);
    padding: 1rem;
    margin: 0 0 1rem;
}

legend { font-weight: 650; padding: 0 0.4rem; }

.choices { display: grid; gap: 0.5rem; }

.choice {
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
    border: var(--border) solid var(--line);
    border-radius: 10px;
    padding: 0.65rem 0.75rem;
    cursor: pointer;
    background: var(--surface);
}

.choice:has(input:checked) { background: #E7EDFF; box-shadow: var(--lift-sm); }
.choice input { margin-top: 0.25rem; }
.choice strong { display: block; }

/* ------------------------------------------------------------- button --- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    font: inherit;
    font-weight: 650;
    padding: 0.6rem 1.1rem;
    border: var(--border) solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    text-decoration: none;
    box-shadow: var(--lift-sm);
    transition: transform 80ms ease, box-shadow 80ms ease;
}

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

.btn:active {
    transform: translate(3px, 3px);
    box-shadow: 0 0 0 var(--ink);
}

.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-dk); color: #fff; }
.btn--danger  { background: var(--danger); color: #fff; }
.btn--danger:hover { color: #fff; }
.btn--quiet   { box-shadow: none; border-color: var(--ink-soft); }
.btn--block   { width: 100%; }

@media (prefers-reduced-motion: reduce) {
    .btn { transition: none; }
    .btn:active { transform: none; }
}

/* -------------------------------------------------------------- flash --- */

.flash {
    border: var(--border) solid var(--line);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    font-weight: 550;
    background: var(--surface);
    box-shadow: var(--lift-sm);
}

.flash--success { background: #DFF3EA; border-color: var(--success); box-shadow: 3px 3px 0 var(--success); }
.flash--error   { background: #FBE4DF; border-color: var(--danger);  box-shadow: 3px 3px 0 var(--danger); }
.flash--info    { background: #FFF4CF; }

/* --------------------------------------------------------------- list --- */

.rows { list-style: none; margin: 0; padding: 0; }

.rows > li {
    padding: 0.9rem 0;
    border-top: 2px solid #DDE2EC;
}

.rows > li:first-child { border-top: 0; }

.rows__title { font-weight: 650; }

.empty {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--ink-soft);
}

/* --------------------------------------------------------- auth pages --- */

.auth {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem 3rem;
}

.auth__panel { width: 100%; max-width: 30rem; }

.auth__brand {
    text-align: center;
    margin-bottom: 1.25rem;
}

.auth__brand .wordmark { font-size: 1.75rem; }

.auth--wide .auth__panel { max-width: 42rem; }

.divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1.25rem 0;
    color: var(--ink-soft);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.divider::before, .divider::after {
    content: '';
    flex: 1;
    height: 2px;
    background: #DDE2EC;
}

.provider-grid { display: grid; gap: 0.5rem; grid-template-columns: 1fr 1fr; }

/* ---------------------------------------------------- repeatable rows --- */

.child-row {
    display: grid;
    gap: 0.5rem;
    grid-template-columns: 1fr;
    padding: 0.75rem;
    border: 2px dashed var(--ink-soft);
    border-radius: 10px;
    margin-bottom: 0.75rem;
}

@media (min-width: 34rem) {
    .child-row { grid-template-columns: 2fr 1fr 1fr; align-items: end; }
}

.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}
