/* ==========================================================================
   Design system
   Clean, neutral UI: soft grays, one confident accent, subtle elevation.
   ========================================================================== */

:root {
    --bg: #f6f7f9;
    --paper: #ffffff;
    --ink: #1a1d23;
    --text-muted: #5b6270;
    --border: #e2e5ea;

    --blue: #2f6690;
    --blue-dark: #24506f;
    --red: #b0483a;
    --yellow: #c99a3f;
    --beige: #efe9db;
    --green: #4f7d5c;
    --orange: #b97a3d;

    --radius: 10px;
    --radius-sm: 6px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.08);
    --shadow-md: 0 4px 16px rgba(16, 24, 40, 0.10);

    /* allauth pages share this palette */
    --auth-bg: var(--bg);
    --auth-card-bg: var(--paper);
    --auth-border: var(--border);
    --auth-text: var(--ink);
    --auth-text-muted: var(--text-muted);
    --auth-primary: var(--blue);
    --auth-primary-dark: var(--blue-dark);
    --auth-danger: var(--red);
    --auth-radius: var(--radius);
}

* {
    box-sizing: border-box;
}

.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;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
}

h1, h2, h3 {
    font-weight: 700;
    letter-spacing: -0.01em;
    margin: 0 0 0.5em;
}

a {
    color: var(--blue);
}

a:hover {
    text-decoration-thickness: 2px;
}

p {
    margin: 0 0 1em;
}

/* --------------------------------------------------------------------------
   Site header + nav
   -------------------------------------------------------------------------- */

.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border);
    background: var(--paper);
}

/* Once scrolled, the full nav row (including the merged login/profile
   item) tucks away behind a hamburger button - only the logo (left) and
   the toggle (right) remain in the compact top row. */
.site-header.is-scrolled .site-nav {
    display: none;
}

.site-header.is-scrolled .nav-toggle {
    display: flex;
}

/* Opening the toggle brings the whole menu back as a dropdown panel
   anchored under the compact header. */
.site-header.is-scrolled.menu-open .site-nav {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    overflow-x: visible;
    position: absolute;
    top: 100%;
    right: 1.2rem;
    width: 240px;
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 0.4rem;
    gap: 0.1rem;
    z-index: 50;
}

.site-header.is-scrolled.menu-open .site-nav li {
    border: none;
}

.nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    flex-direction: column;
    width: 2.6rem;
    height: 2.6rem;
    background: transparent;
    color: var(--ink);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    margin-left: auto;
}

.nav-toggle:hover {
    border-color: var(--blue);
}

.nav-toggle-bar {
    display: block;
    width: 1.3rem;
    height: 2px;
    background: currentColor;
}

.site-header-inner {
    position: relative;
    max-width: 1080px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    padding: 0 1.2rem;
}

.site-header-top {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
}

/* When the nav row hides behind the hamburger, the logo row is the only
   thing left in the header - let it grow to fill the width so the
   toggle button's margin-left:auto still lands at the far right edge. */
.site-header.is-scrolled .site-header-top {
    flex: 1 1 auto;
}

.brand-tile {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.9rem 0;
    color: var(--ink);
    font-weight: 700;
    font-size: 1.1rem;
    text-decoration: none;
}

.brand-tile:hover {
    color: var(--blue);
}

.site-nav {
    list-style: none;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.15rem;
    flex: 1 1 auto;
    margin: 0;
    padding: 0;
}

.site-nav li {
    border: none;
}

.nav-tile {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0.55rem 0.85rem;
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.92rem;
    background: transparent;
    border-radius: var(--radius-sm);
    transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-tile:hover {
    background: var(--bg);
    color: var(--ink);
}

/* --------------------------------------------------------------------------
   Auth item (login state), set apart from the page-link nav items as its
   own compact chip rather than another item in the same row.
   -------------------------------------------------------------------------- */

.site-nav li.nav-auth {
    margin-left: 0.5rem;
    padding-left: 0.6rem;
    border-left: 1px solid var(--border);
}

.site-nav li.nav-auth .nav-tile {
    color: var(--blue);
}

.nav-tile-account {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0.4rem 0.2rem;
}

.account-menu {
    position: relative;
}

.account-trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.4rem;
    height: 2.4rem;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--ink);
    cursor: pointer;
    font: inherit;
}

.account-trigger:hover {
    border-color: var(--blue);
    color: var(--blue);
}

.account-icon {
    width: 1.3rem;
    height: 1.3rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.account-dropdown {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    min-width: 190px;
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 0.4rem;
    gap: 0.1rem;
    z-index: 20;
}

.account-menu:hover .account-dropdown,
.account-menu:focus-within .account-dropdown {
    display: flex;
}

.account-dropdown a,
.account-dropdown button {
    display: block;
    width: 100%;
    box-sizing: border-box;
    text-align: left;
    background: transparent;
    color: var(--ink);
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.7rem;
    font: inherit;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
}

.account-dropdown a:hover,
.account-dropdown button:hover {
    background: var(--bg);
}

/* --------------------------------------------------------------------------
   Page frame + tile grid (used for StreamField body & homepage sections)
   -------------------------------------------------------------------------- */

.mondrian-frame {
    max-width: 1080px;
    margin: 2.5rem auto;
    padding: 0 1.2rem 3rem;
}

.page-banner {
    margin-bottom: 1.75rem;
}

.page-banner h1 {
    margin: 0;
    font-size: 1.8rem;
}

.tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
    container-type: inline-size;
    container-name: tile-grid;
}

.tile {
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1.4rem;
}

a.tile {
    display: block;
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}

a.tile:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--blue);
    transform: translateY(-2px);
}

.tile > *:last-child {
    margin-bottom: 0;
}

.tile img {
    max-width: 100%;
    height: auto;
    display: block;
}

.tile-heading {
    font-weight: 700;
    font-size: 1.15rem;
    margin: 0 0 0.4rem;
    color: var(--ink);
}

/* --------------------------------------------------------------------------
   Milestone timeline tiles (previous / current / next), used on the
   Actions page - background color is the primary signal: grey for past,
   light green for the currently-achieved one, white for what's ahead.
   -------------------------------------------------------------------------- */

.tile-grid > .tile.tile--milestone-previous {
    background: #eef0f3;
}

.tile--milestone-previous .tile-heading,
.tile--milestone-previous p {
    text-decoration: line-through;
    color: var(--text-muted);
}

.tile-grid > .tile.tile--milestone-current {
    background: #e8f4ec;
    border: 2px solid var(--green);
    box-shadow: var(--shadow-md);
}

.tile--milestone-current .tile-heading {
    font-size: 1.6rem;
    color: var(--green);
}

/* Make the current milestone stand out from its row/column neighbors by
   growing taller when tiles sit side by side (grid rows auto-size to
   their tallest cell, so extra padding alone achieves this). 490px is
   where a second 240px tile plus the grid gap starts to fit next to it,
   i.e. where auto-fill would add a second column. */
@container tile-grid (min-width: 490px) {
    .tile--milestone-current {
        padding-top: 2.4rem;
        padding-bottom: 2.4rem;
    }
}

.tile-grid > .tile.tile--milestone-next {
    background: var(--paper);
}

.tile--milestone-next .tile-heading {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
}

.tile--milestone-next p {
    font-weight: 400;
    color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   Content panel (StandardPage body) - one single container, not per-block tiles
   -------------------------------------------------------------------------- */

.content-panel {
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1.8rem 2rem;
}

.content-panel > *:last-child {
    margin-bottom: 0;
}

.content-panel p,
.content-panel ul,
.content-panel ol {
    margin: 0 0 1.1em;
    max-width: 68ch;
}

.content-panel img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 0 1.1em;
    border-radius: var(--radius-sm);
}

.content-heading {
    font-size: 1.35rem;
    margin: 1.4em 0 0.6em;
    padding-bottom: 0.4em;
    border-bottom: 2px solid var(--border);
    color: var(--ink);
}

.content-panel > .content-heading:first-child {
    margin-top: 0;
}

.narrow-form {
    max-width: 480px;
}

.block-spacer {
    height: 2rem;
}

/* --------------------------------------------------------------------------
   Role picker (User / Guardian)
   -------------------------------------------------------------------------- */

.role-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.role-card {
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1.6rem;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.role-card p {
    flex: 1;
    margin: 0;
    color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   Homepage hero
   -------------------------------------------------------------------------- */

.hero {
    padding: 3.5rem 0 3rem;
    margin: 0 0 0.5rem;
    border-bottom: 1px solid var(--border);
}

.hero h1 {
    font-size: 2.25rem;
    margin-bottom: 0.6rem;
}

.hero-subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
    max-width: 46ch;
    margin: 0;
}

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

.btn {
    display: inline-block;
    background: var(--blue);
    color: var(--paper);
    text-decoration: none;
    font-weight: 600;
    padding: 0.65rem 1.3rem;
    border: 1px solid var(--blue);
    border-radius: var(--radius-sm);
    transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.btn:hover {
    background: var(--blue-dark);
    border-color: var(--blue-dark);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */

.site-footer {
    border-top: 1px solid var(--border);
    background: var(--paper);
    color: var(--text-muted);
    padding: 1.6rem 1.2rem;
    text-align: center;
    font-size: 0.85rem;
}

.site-footer p {
    margin: 0;
}

.site-footer a {
    color: var(--blue);
}

/* --------------------------------------------------------------------------
   404
   -------------------------------------------------------------------------- */

.error-frame {
    max-width: 480px;
    margin: 5rem auto;
    padding: 0 1.2rem;
    text-align: center;
}

.error-code {
    font-size: 4.5rem;
    font-weight: 700;
    color: var(--border);
    margin: 0 0 0.25rem;
}

/* --------------------------------------------------------------------------
   Search
   -------------------------------------------------------------------------- */

.search-form {
    display: flex;
    gap: 0.6rem;
    margin-bottom: 2rem;
}

.search-form input[type="text"] {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.9rem;
    font-size: 1rem;
    background: var(--paper);
}

.search-form input[type="text"]:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(47, 102, 144, 0.15);
}

.search-form input[type="submit"] {
    border: none;
    border-radius: var(--radius-sm);
    background: var(--blue);
    color: var(--paper);
    padding: 0.65rem 1.4rem;
    font-weight: 600;
    cursor: pointer;
}

.search-form input[type="submit"]:hover {
    background: var(--blue-dark);
}

.search-results {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.search-results li {
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.2rem;
}

.search-pagination {
    margin-top: 1.5rem;
    display: flex;
    gap: 1rem;
}

/* ==========================================================================
   allauth pages (login, signup, 3rd-party signup, password reset, ...)
   Reuses the design system's palette above via the --auth-* variables.
   ========================================================================== */

.auth-body {
    margin: 0;
    background: var(--bg);
    min-height: 100vh;
}

.auth-page {
    max-width: 420px;
    margin: 0 auto;
    padding: 3rem 1.25rem;
}

.auth-topbar {
    display: inline-block;
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
    color: var(--auth-text-muted);
    text-decoration: none;
}

.auth-topbar:hover {
    color: var(--auth-text);
}

.auth-card {
    background: var(--auth-card-bg);
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius);
    box-shadow: var(--shadow-md);
    padding: 2.2rem;
}

.auth-h1 {
    font-size: 1.4rem;
    margin: 0 0 0.75rem;
}

.auth-h2 {
    font-size: 1rem;
    font-weight: 600;
    margin: 1.5rem 0 0.75rem;
    color: var(--auth-text-muted);
}

.auth-p {
    font-size: 0.95rem;
    color: var(--auth-text-muted);
    line-height: 1.5;
}

.auth-p a {
    color: var(--auth-primary);
}

.auth-hr {
    border: none;
    border-top: 1px solid var(--auth-border);
    margin: 1.5rem 0;
}

.auth-alert {
    background: #fbf3e2;
    border: 1px solid var(--yellow);
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.85rem;
    font-size: 0.9rem;
}

.auth-messages {
    list-style: none;
    margin: 0 0 1.25rem;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.auth-message {
    border: 1px solid var(--auth-border);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.85rem;
    font-size: 0.9rem;
    background: var(--paper);
    color: var(--auth-text);
}

.auth-message--error {
    background: #fbeae7;
    color: var(--auth-danger);
    border-color: var(--auth-danger);
}

.auth-message--success {
    background: #e7f3ea;
    color: #2c6b40;
    border-color: #2c6b40;
}

.auth-form,
.auth-field {
    display: block;
}

.auth-form p {
    margin: 0 0 1rem;
}

.auth-form label,
.auth-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
    color: var(--ink);
}

.auth-label--check {
    display: inline;
    font-weight: 400;
    margin-left: 0.4rem;
}

.auth-form input:not([type="checkbox"]):not([type="radio"]),
.auth-form select,
.auth-form textarea,
.auth-input:not(.auth-input--check) {
    width: 100%;
    box-sizing: border-box;
    padding: 0.6rem 0.75rem;
    font-size: 0.95rem;
    border: 1px solid var(--auth-border);
    border-radius: var(--radius-sm);
    background: var(--auth-card-bg);
    color: var(--auth-text);
}

.auth-form input:focus,
.auth-input:focus {
    outline: none;
    border-color: var(--auth-primary);
    box-shadow: 0 0 0 3px rgba(47, 102, 144, 0.15);
}

.auth-form .helptext,
.auth-help {
    display: block;
    font-size: 0.8rem;
    color: var(--auth-text-muted);
    margin-top: 0.3rem;
}

.auth-form ul.errorlist,
.auth-field-errors {
    list-style: none;
    margin: 0 0 0.5rem;
    padding: 0.55rem 0.75rem;
    background: #fbeae7;
    color: var(--auth-danger);
    border: 1px solid var(--auth-danger);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}

.auth-field-errors ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.auth-form-actions {
    margin-top: 1.25rem;
}

.richtext-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-bottom: 0.5rem;
}

.richtext-btn {
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--ink);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0.35rem 0.65rem;
}

.richtext-btn:hover {
    background: var(--bg);
    border-color: var(--blue);
}

.richtext-editable {
    min-height: 140px;
    max-height: 360px;
    overflow-y: auto;
    text-align: left;
    border: 1px solid var(--auth-border);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.75rem;
}

.richtext-editable ul,
.richtext-editable ol {
    margin: 0 0 0.5em 1.2em;
    padding: 0;
}

.richtext-editable p {
    margin: 0 0 0.5em;
}

.richtext-editable:focus {
    outline: none;
    border-color: var(--auth-primary);
    box-shadow: 0 0 0 3px rgba(47, 102, 144, 0.15);
}

.auth-btn {
    display: inline-block;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
    padding: 0.65rem 1rem;
    font-size: 0.95rem;
    font-weight: 600;
    border: 1px solid var(--auth-primary);
    border-radius: var(--radius-sm);
    background: var(--auth-primary);
    color: var(--paper);
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.auth-btn:hover {
    background: var(--auth-primary-dark);
    border-color: var(--auth-primary-dark);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.auth-btn--outline {
    background: var(--auth-card-bg);
    color: var(--ink);
    border-color: var(--auth-border);
}

.auth-btn--outline:hover {
    background: var(--bg);
    border-color: var(--auth-primary);
}

.auth-btn--provider {
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-button-group {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 1rem;
}

.auth-provider-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.auth-panel {
    margin-bottom: 1.5rem;
}

.auth-panel-actions {
    list-style: none;
    margin: 0.5rem 0 0;
    padding: 0;
}
