/* ============================================================
   Oak-Ed – Web Awesome base styles
   ============================================================ */

/* --- Fonts: self-hosted, not the Google Fonts CDN ----------------------
   These live here rather than in a per-surface stylesheet because this file
   is the one thing every Oak-Ed surface loads — including the static games
   catalogue, which Caddy serves off disk and which links this file over
   /static/.

   Not the CDN, for two reasons. Privacy: these pages know who is reading
   (the shared header shows the signed-in learner's name) and children load
   them, so they shouldn't leak viewer IPs and referrers to a third party.
   The static catalogue used the CDN back when it was anonymous — bringing it
   into the shared, viewer-aware chrome is what changed that. Reliability:
   Caveat and Patrick Hand are used throughout the games' own gameplay UI, not
   just as decoration, so a blocked or slow third-party request is a visibly
   broken game rather than a cosmetic wobble.

   collectstatic + WhiteNoise give hashing, far-future caching and
   compression, and ManifestStaticFilesStorage rewrites the relative url()
   refs below automatically. Licences: static/fonts/OFL.txt. */
@font-face {
    font-family: 'EB Garamond';
    src: url("../fonts/EBGaramond-Variable.f12bc30ca94a.woff2") format('woff2');
    font-weight: 400 600;  /* one variable file covers the whole range */
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'EB Garamond';
    src: url("../fonts/EBGaramond-Italic-Variable.985f75b87984.woff2") format('woff2');
    font-weight: 400 600;
    font-style: italic;
    font-display: swap;
}
@font-face {
    font-family: 'Patrick Hand';
    src: url("../fonts/PatrickHand-Regular.56bc7c81e5da.woff2") format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Caveat';
    src: url("../fonts/Caveat-Variable.2d9de14f93a2.woff2") format('woff2');
    font-weight: 400 700;
    font-style: normal;
    font-display: swap;
}

html, body {
    min-height: 100%;
    padding: 0;
    margin: 0;
}

/* wa-page banner — logo strip above the header */
.site-banner {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 1.5rem;
    font-size: 0.8125rem;
}
.site-banner-logo {
    height: 52px;
    width: auto;
}

/* Header layout: brand left, user dropdown right */
.site-header {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-height: 3.25rem;
    padding: 0.5rem 1.5rem;
}
.site-header__top {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 1rem;
}
.site-header__user {
    flex-shrink: 0;
    margin-left: auto;
}
.site-header .brand {
    text-decoration: none;
    font-weight: 700;
    font-size: 1.1rem;
    display: inline-flex;
    align-items: center;
}

/* Sidebar width — only reserve a column on desktop; on mobile the nav is a drawer */
wa-page {
    --menu-width: 200px;
}
wa-page[view="mobile"] {
    --menu-width: 0;
}

/* Main layout */
.page-main {
    padding: 2rem 1.5rem;
    max-width: 1280px;
    margin: 0 auto;
}

/* Page header row */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}
.page-header h1,
.page-header h2 {
    margin: 0;
}

/* Small uppercase heading used at the top of stat / chart cards */
.card-heading {
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

/* Grid layouts */
.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}
.grid-2-1 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    align-items: start;
}
.centered {
    max-width: 900px;
    margin: 0 auto;
}
.centered-sm {
    max-width: 560px;
    margin: 0 auto;
}

/* Content cards */
.content-card {
    border-radius: 0.75rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.content-card-light {
    border-radius: 0.5rem;
    padding: 1rem;
}
.content-card-flush {
    padding: 0;
    overflow: hidden;
}

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.data-table th {
    text-align: left;
    padding: 0.625rem 0.875rem;
    font-weight: 600;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.data-table td {
    padding: 0.75rem 0.875rem;
    vertical-align: middle;
}
.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* Form fields (for Django-rendered native inputs) */
.form-field {
    margin-bottom: 1rem;
}
.form-field > label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.3rem;
}
.form-field input[type="text"],
.form-field input[type="email"],
.form-field input[type="number"],
.form-field input[type="password"],
.form-field input[type="search"],
.form-field input[type="url"],
.form-field select,
.form-field textarea {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    box-sizing: border-box;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-field select[multiple] {
    height: auto;
    padding: 0.25rem;
}
.form-field select[multiple] option {
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
}
.form-field input[type="checkbox"],
.filterable-checkbox-list input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    width: 1.125rem;
    height: 1.125rem;
    border: 2px solid var(--wa-color-neutral-400, #9ca3af);
    border-radius: 0.25rem;
    background: #fff;
    cursor: pointer;
    vertical-align: middle;
    margin-right: 0.375rem;
    flex-shrink: 0;
}
.form-field input[type="checkbox"]:focus-visible,
.filterable-checkbox-list input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--wa-color-brand-600, #3b82f6);
    outline-offset: 2px;
}
.form-field input[type="checkbox"]:checked,
.filterable-checkbox-list input[type="checkbox"]:checked {
    background-color: var(--wa-color-brand-600, #3b82f6);
    border-color: var(--wa-color-brand-600, #3b82f6);
}
.field-error {
    font-size: 0.8125rem;
    margin-top: 0.25rem;
}
.field-help {
    font-size: 0.8125rem;
    margin-top: 0.25rem;
}

/* Input with addon button (e.g. ISBN + Fetch) */
.input-addon {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
}
.input-addon > *:first-child {
    flex: 1;
}

/* Badge lists */
.badge-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    align-items: center;
}

/* A <wa-tag> that is the content of a link — the <a> carries the href, so the
   chip navigates as a plain link and needs no click handler. */
a.chip-link {
    text-decoration: none;
}

/* Button rows */
.button-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0;
    font-size: 0.875rem;
    list-style: none;
    padding: 0;
    margin: 0 0 1.25rem;
}
.breadcrumb li {
    display: flex;
    align-items: center;
}
.breadcrumb li + li::before {
    content: '/';
    margin: 0 0.5rem;
}
.breadcrumb a {
    text-decoration: none;
}
.breadcrumb a:hover {
    text-decoration: underline;
}
/* The current page is a <span>, not a focusable dummy link: nothing to
   neutralise, just keep it visually distinct from the crumbs you can click. */
.breadcrumb .active {
    color: var(--wa-color-neutral-700, inherit);
}

/* ---------------------------------------------------------------------------
   Portal chrome — the shared header for learner.*, games.* and library.*
   (templates/portal_base.html + partials/portal_sitebar.html).

   Sibling of the .site-header / wa-page chrome above, which is the teacher
   surface. Both live in this file on purpose: one stylesheet is what makes the
   four surfaces one design system. These rules are also the ONLY styling the
   static games catalogue gets — those pages link this file but load no
   WebAwesome kit, so every colour below must keep its literal fallback.
   --------------------------------------------------------------------------- */
.portal-header {
    border-bottom: 1px solid var(--wa-color-neutral-200, #e5e7eb);
    background: var(--wa-color-neutral-0, #fff);
}
.portal-sitebar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.5rem;
    max-width: 1280px;
    margin: 0 auto;
}
.portal-sitebar__brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: inherit;
    font-weight: 700;
}
.portal-sitebar__brand img {
    height: 1.75rem;
    width: auto;
}
.portal-sitebar__wordmark {
    font-size: 1.05rem;
    /* The site name comes from the host label (games / library / learner), so
       it arrives lowercase; small-caps reads as a wordmark rather than a typo. */
    font-variant: small-caps;
    color: var(--wa-color-neutral-600, #4b5563);
}
.portal-sitebar__nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.portal-sitebar__link {
    color: var(--wa-color-neutral-600, #4b5563);
    text-decoration: none;
    font-size: 0.95rem;
    padding: 0.25rem 0;
    border-bottom: 2px solid transparent;
}
.portal-sitebar__link:hover {
    color: var(--wa-color-brand-600, #2563eb);
}
/* The current site renders as a <span>, not an <a> — styled to read as "you
   are here" rather than as a disabled link. */
.portal-sitebar__link--current {
    color: var(--wa-color-neutral-900, #111827);
    font-weight: 600;
    border-bottom-color: var(--wa-color-brand-500, #2563eb);
}
.portal-sitebar__viewer {
    margin-left: auto;
    font-size: 0.9rem;
    color: var(--wa-color-neutral-600, #4b5563);
}

/* Per-portal second row: each portal fills {% block localnav %} with its own
   destinations (lessons, trophy case, mail …). Empty on portals that have none,
   and an empty block collapses to nothing rather than an empty bar. */
.portal-localnav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1.25rem;
    padding: 0 1.5rem 0.75rem;
    max-width: 1280px;
    margin: 0 auto;
}
.portal-localnav a {
    color: var(--wa-color-neutral-700, #374151);
    text-decoration: none;
    font-size: 0.95rem;
}
.portal-localnav a:hover {
    color: var(--wa-color-brand-600, #2563eb);
}
.portal-localnav a[aria-current="page"] {
    color: var(--wa-color-neutral-900, #111827);
    font-weight: 600;
}

.portal-main {
    padding: 2rem 1.5rem;
    max-width: 1280px;
    margin: 0 auto;
}

/* Learner-portal tiles. Bigger hit targets and a calmer feel than the dense
   teacher tooling — these were an inline <style> block in the learner base
   until the portals were unified. */
.portal-greeting {
    text-align: center;
    padding: 1rem 1rem 0;
}
.portal-greeting h1 {
    font-size: 2rem;
    margin: 0;
}
.portal-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    max-width: 36rem;
    margin: 2rem auto;
}
@media (min-width: 640px) {
    .portal-grid {
        grid-template-columns: 1fr 1fr;
    }
}
.portal-tile {
    display: block;
    padding: 1.5rem;
    border-radius: 1rem;
    border: 2px solid var(--wa-color-neutral-200, #e5e7eb);
    text-decoration: none;
    color: inherit;
    transition: transform 120ms ease, border-color 120ms ease;
    min-height: 6rem;
}
.portal-tile:hover,
.portal-tile:focus {
    border-color: var(--wa-color-brand-500, #2563eb);
    transform: translateY(-2px);
}
.portal-tile h2 {
    margin: 0 0 0.25rem;
    font-size: 1.5rem;
}
.portal-tile p {
    margin: 0;
    color: var(--wa-color-neutral-600, #4b5563);
}

@media (max-width: 640px) {
    .portal-sitebar {
        flex-wrap: wrap;
        gap: 0.5rem 1rem;
        padding: 0.75rem 1rem;
    }
    .portal-sitebar__viewer {
        /* Drop the viewer name onto its own line rather than squeezing the
           nav — the nav is the part a child needs to reach. */
        margin-left: 0;
        flex-basis: 100%;
    }
    .portal-localnav {
        padding: 0 1rem 0.75rem;
    }
    .portal-main {
        padding: 1.5rem 1rem;
    }
}

/* Motion is decorative here; children using switch access or with vestibular
   sensitivity should not have to fight it. */
@media (prefers-reduced-motion: reduce) {
    .portal-tile {
        transition: none;
    }
    .portal-tile:hover,
    .portal-tile:focus {
        transform: none;
    }
}

/* Meta info flex row (title + date) */
.meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

/* htmx indicator */
.htmx-indicator { opacity: 0; transition: opacity 200ms; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { opacity: 1; }

/* Dialogs */
wa-dialog {
    --width: 520px;
}

/* Text helpers */
.text-muted {
    font-size: 0.875rem;
}
.text-sm  { font-size: 0.875rem; }
.text-xs  { font-size: 0.75rem; }
.text-base { font-size: 1rem; }
.text-lg  { font-size: 1.1rem; }
.text-center { text-align: center; }

/* Spacing */
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-5 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }

/* Layout */
.w-full  { width: 100%; }
.hidden  { display: none; }
.grid-2  { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.font-mono { font-family: monospace; font-size: 0.85rem; }

/* Empty table / list state */
.empty-state {
    text-align: center;
    padding: 2rem;
}

/* Prose / markdown-rendered content */
.content { line-height: 1.7; }
.content p { margin: 0 0 0.875rem; }
.content p:last-child { margin-bottom: 0; }
.content h1, .content h2, .content h3,
.content h4, .content h5, .content h6 {
    font-weight: 600;
    line-height: 1.3;
    margin: 1.5rem 0 0.5rem;
}
.content h1 { font-size: 1.75rem; }
.content h2 { font-size: 1.4rem; }
.content h3 { font-size: 1.15rem; }
.content ul, .content ol { padding-left: 1.5rem; margin: 0 0 0.875rem; }
.content li { margin-bottom: 0.25rem; }
.content code {
    font-family: monospace;
    font-size: 0.875em;
    padding: 0.1em 0.35em;
    border-radius: 0.25rem;
}
.content pre {
    border-radius: 0.5rem;
    padding: 1rem 1.25rem;
    overflow-x: auto;
    font-size: 0.875rem;
    margin: 0 0 0.875rem;
}
.content blockquote {
    margin: 0 0 0.875rem;
    padding: 0.25rem 0 0.25rem 1rem;
}
.content a {
    text-decoration: none;
}
.content a:hover { text-decoration: underline; }
.content hr {
    border: none;
    margin: 1.25rem 0;
}
.content strong { font-weight: 600; }

/* Subtitle style */
.page-subtitle {
    font-size: 0.9375rem;
    margin-top: 0.25rem;
}

/* ============================================================
   Sidebar navigation (wa-page navigation slot)
   ============================================================ */

.drawer-nav {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    padding: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.75rem;
    min-height: 44px;
    border-radius: var(--wa-border-radius-medium, 0.375rem);
    color: var(--wa-color-neutral-700, #374151);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background-color 0.15s, color 0.15s;
}

.nav-link:hover {
    background-color: rgba(0, 0, 0, 0.06);
    color: var(--wa-color-neutral-900, #111);
    text-decoration: none;
}

.nav-link.active {
    background-color: var(--wa-color-brand-100, #dcfce7);
    color: var(--wa-color-brand-700, #15803d);
    font-weight: 600;
}

.nav-link wa-icon {
    font-size: 0.875rem;
    width: 1rem;
    flex-shrink: 0;
}

.data-table tbody tr {
    transition: background-color 0.1s;
}
.data-table tbody tr:hover {
    background-color: var(--wa-color-neutral-90, #f9fafb);
}

/* ============================================================
   Responsive (desktop-first: max-width overrides)
   ============================================================ */

/* Table scroll wrapper — always active so overflow:hidden on the card never clips content */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* 768px — grids collapse, header tightens */
@media (max-width: 768px) {
    .grid-3, .grid-2-1, .grid-2 { grid-template-columns: 1fr; }
    .site-header { padding: 0.375rem 0.75rem; }
    .site-banner-logo { height: 40px; }
    .page-main { padding: 1.5rem 1rem; }
}

/* 480px — phone portrait adjustments */
@media (max-width: 480px) {
    .page-main { padding: 1rem 0.75rem; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
    wa-dialog { --width: min(520px, calc(100vw - 2rem)); }
}

/* Dashboard overdue alert.
   Intentionally uses explicit hex rather than the --wa-color-danger-* theme
   tokens: that palette's danger shade rendered as a saturated block that was
   too harsh here, so these soft red values were chosen deliberately for a
   calmer alert. */
.dashboard-overdue {
    margin-bottom: 1.5rem;
    border-left: 4px solid #ef4444;
    background: #fef2f2;
}

.dashboard-overdue__heading {
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.625rem;
    color: #991b1b;
}

.dashboard-overdue__row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.375rem 0;
    border-bottom: 1px solid #fecaca;
}

.dashboard-overdue__row:last-child {
    border-bottom: none;
}

.dashboard-overdue__learner {
    font-weight: 500;
    font-size: 0.875rem;
}

.dashboard-overdue__link {
    font-size: 0.875rem;
    font-weight: 600;
    color: #b91c1c;
    text-decoration: none;
    white-space: nowrap;
}

/* Filterable checkbox tag selector */
.filterable-checkbox-list {
    border: 1px solid var(--wa-color-neutral-200, #e5e7eb);
    border-radius: 0.375rem;
    padding: 0.5rem;
}

.filterable-checkbox-search {
    width: 100%;
    margin-bottom: 0.5rem;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--wa-color-neutral-300, #d1d5db);
    border-radius: 0.25rem;
    font-size: 0.875rem;
    box-sizing: border-box;
}

.filterable-checkbox-list .checkbox-scroll {
    max-height: 180px;
    overflow-y: auto;
}

.filterable-checkbox-list ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Internal mail — shared by the teacher pages and the learner portal
   (both surfaces load this stylesheet). Scoped under .mail-*. */
.mail-page {
    max-width: 36rem;
    margin: 1.5rem auto;
    padding: 0 1rem;
}

.mail-card--compose { max-width: 36rem; }
.mail-card--thread { max-width: 42rem; }

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

.mail-thread__item { margin-bottom: 0.75rem; }

.mail-thread__item--mine { text-align: right; }

.mail-thread__bubble {
    display: inline-block;
    max-width: 80%;
    text-align: left;
    padding: 0.5rem 0.75rem;
    border-radius: 0.75rem;
    background: var(--wa-color-neutral-50, #f9fafb);
}

.mail-thread__bubble--mine { background: var(--wa-color-brand-50, #eff6ff); }

.mail-thread__meta { margin-bottom: 0.15rem; }

.mail-thread__body { white-space: pre-wrap; }

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

.mail-conversation-list__item {
    border-bottom: 1px solid var(--wa-color-neutral-100, #f3f4f6);
    padding: 0.6rem 0;
}

.mail-conversation-list__link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
    color: inherit;
}

.mail-conversation-list__time { margin-left: auto; }

.mail-disclosure { margin-bottom: 1rem; }

/* Fits both placements: below a thread (needs top margin) and at the top
   of a compose form (needs bottom margin). */
.mail-error { margin: 0.75rem 0 1rem; }

.mail-reply-form { margin-top: 1rem; }

.mail-form__label {
    display: block;
    margin-bottom: 0.25rem;
}

.mail-form__field {
    display: block;
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 1rem;
    padding: 0.4rem;
}

.mail-form__field--reply { margin-bottom: 0.5rem; }

/* Learner portal: larger type and touch targets for children. */
.mail-page .mail-form__field {
    padding: 0.5rem;
    font-size: 1.1rem;
}

/* Learner inbox tiles */
.mail-tile-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.mail-tile-list__item { margin-bottom: 0.5rem; }

.mail-tile {
    min-height: auto;
    padding: 1rem;
}

.mail-tile__name { font-size: 1.2rem; }

.mail-compose-tile { margin-bottom: 1rem; }

.mail-empty { text-align: center; }
