/* ─────────────────────────────────────────────────────────────────────────────
   Landing page — class-first subject grid.

   Colours come from the ported CI2 palette only: #871619 maroon, #EB8F00 orange,
   #1a2229 hero. The per-subject tile colours stay in main.css, keyed off the
   whitespace-stripped subject name exactly as CI2 keyed them.

   The tiles used to be CSS flip cards whose BACK held the form links, so on a
   touch screen the forms were unreachable and 11 tiles rendered white-on-white
   (Civics 1.45:1, Biology 1.73:1). Here the tile is a flat block: a name that
   links to the subject, and a chip per form under it.
   ──────────────────────────────────────────────────────────────────────────── */

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

/* ── Hero ─────────────────────────────────────────────────────────────────── */
.sd-home-hero {
    background: #1a2229;
    padding: 28px 0 26px;
}
.sd-home-hero .home-header { margin: 0 0 6px; }
.sd-home-sub {
    margin: 0 0 18px;
    color: #c8ccd0;
    font-size: 14px;
}

.sd-home-pick {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
}
.sd-home-pick-label {
    color: #9aa2a8;
    font-size: 13px;
    flex: 0 0 auto;
}
.sd-chipset { display: flex; flex-wrap: wrap; gap: 6px; }
/* A visible seam between "which school" and "which year". */
.sd-chipset-class { padding-left: 10px; border-left: 1px solid #39424a; }

.sd-chip {
    margin: 0;
    padding: 6px 14px;
    background: transparent;
    border: 1px solid #5c666e;
    border-radius: 3px;
    color: #dfe3e6;
    font-size: 13px;
    font-weight: normal;
    line-height: 1.2;
    cursor: pointer;
}
.sd-chip:hover { background: #263038 !important; color: #ffffff !important; border-color: #7d8790; }
.sd-chip.is-on,
.sd-chip.is-on:hover {
    background: #EB8F00 !important;
    border-color: #EB8F00;
    color: #3d2400 !important;
    font-weight: bold;
}
.sd-chip:focus-visible { outline: 2px solid #EB8F00; outline-offset: 2px; }

.sd-home-search { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.sd-home-search input[type="search"] {
    width: 340px;
    max-width: 100%;
    height: 34px;
    margin: 0;
    padding: 0 12px;
    background: #ffffff;
    border: 1px solid #ffffff;
    border-radius: 4px;
    box-shadow: none;
    font-size: 13px;
}
.sd-home-search input[type="search"]:focus { border-color: #EB8F00; outline: none; }
.sd-home-search-note { color: #8d959b; font-size: 12px; }

/* ── Section head ─────────────────────────────────────────────────────────── */
.sd-home-body { padding: 22px 0 8px; }
.sd-home-head {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding-bottom: 8px;
    margin-bottom: 16px;
    border-bottom: 1px solid #871619;
}
.sd-home-title { margin: 0; font-size: 18px; color: #871619; }
.sd-home-tag {
    padding: 2px 10px;
    border-radius: 10px;
    background: #f7efe1;
    color: #7a4a00;
    font-size: 11px;
    font-weight: bold;
}
.sd-home-count { margin-left: auto; color: #8a8a8a; font-size: 12px; }
.sd-home-empty { color: #7a7a7a; font-size: 14px; padding: 16px 0; }

/* ── Subject cards (CI2 flip, rebuilt) ───────────────────────────────────────
   CI2 flipped `.card__front` / `.card__back` on :hover inside a fixed 176x110 box.
   Same mechanics — backface-visibility, rotateY, 0.6s — but sized by the grid, and
   flipped by hover, tap AND keyboard focus. Hover alone is why the class links were
   unreachable on a phone. */
.sd-subject-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.sd-flip {
    position: relative;
    height: 122px;
    perspective: 900px;
    cursor: pointer;
    outline: none;
}
.sd-flip-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform .6s;
    transform-style: preserve-3d;
}
.sd-flip:hover .sd-flip-inner,
.sd-flip:focus-visible .sd-flip-inner,
.sd-flip.is-flipped .sd-flip-inner { transform: rotateY(180deg); }
.sd-flip:focus-visible { box-shadow: 0 0 0 3px #EB8F00; border-radius: 6px; }

.sd-flip-face {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    padding: 12px 14px 14px;
    border-radius: 6px;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    overflow: hidden;
}
.sd-flip-back { transform: rotateY(180deg); }

/* The icon is the card's subject, not a decoration in the corner: centred, large and
   solid enough to recognise across a grid. It inherits the label colour, so one icon
   serves both light and dark fills. */
.sd-flip-icon {
    flex: 1 1 auto;
    width: 100%;
    max-height: 56px;
    margin-top: 4px;
    color: #ffffff;
    opacity: .95;
    pointer-events: none;
}
.sd-flip:hover .sd-flip-icon { opacity: 1; }

.sd-flip-name {
    position: relative;
    color: #ffffff;
    font-size: 15px;
    font-weight: bold;
    line-height: 1.25;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .45);
}
.sd-flip-back-icon {
    width: 15px;
    height: 15px;
    vertical-align: -3px;
    margin-right: 3px;
}
.sd-flip-back-name {
    color: rgba(255, 255, 255, .85);
    font-size: 11px;
    margin-bottom: 8px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .45);
}
.sd-flip-forms {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    align-content: flex-start;
}
.sd-flip-forms li { margin: 0; }
.sd-flip-forms a {
    display: block;
    padding: 4px 10px;
    border-radius: 3px;
    background: rgba(0, 0, 0, .38);
    color: #ffffff !important;
    font-size: 12px;
    line-height: 1.3;
    text-decoration: none;
    white-space: nowrap;
}
.sd-flip-forms a:hover,
.sd-flip-forms a:focus { background: #ffffff; color: #1a2229 !important; }

/* LIGHT fills take dark text — CI2 painted every label white, so its own light fills
   (Civics #EED81A at 1.45:1, Biology #AAD400 at 1.73:1) were unreadable. Which fills
   are light is computed from relative luminance in PHP, so a subject CI2 never named
   is covered too. */
.sd-flip.is-light .sd-flip-name { color: #1a2229; text-shadow: none; }
.sd-flip.is-light .sd-flip-icon { color: #1a2229; opacity: .82; }
.sd-flip.is-light .sd-flip-back-name { color: rgba(0, 0, 0, .66); text-shadow: none; }
.sd-flip.is-light .sd-flip-forms a { background: rgba(255, 255, 255, .8); color: #1a2229 !important; }
.sd-flip.is-light .sd-flip-forms a:hover,
.sd-flip.is-light .sd-flip-forms a:focus { background: #1a2229; color: #ffffff !important; }

/* The previous curriculum keeps each subject's colour but sits back a little, so the
   two grids never read as equals. */
.sd-subject-grid.is-legacy .sd-flip-inner { opacity: .82; }
.sd-subject-grid.is-legacy .sd-flip:hover .sd-flip-inner { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
    .sd-flip-inner { transition: none; }
}

/* ── Curriculum tabs ──────────────────────────────────────────────────────────
   Both curricula are visible, one grid at a time. A text button hid the previous
   curriculum entirely; two grids at once is what produced 23 duplicate tiles. */
.sd-curr-tabs {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: -6px 0 16px;
}
.sd-curr-tab {
    margin: 0;
    padding: 7px 14px;
    background: #f4f4f4;
    border: 1px solid #e2e2e2;
    border-radius: 4px;
    color: #5a5a5a;
    font-size: 13px;
    font-weight: normal;
    cursor: pointer;
}
.sd-curr-tab:hover { background: #ececec !important; color: #333333 !important; }
.sd-curr-tab.is-on,
.sd-curr-tab.is-on:hover {
    background: #871619 !important;
    border-color: #871619;
    color: #ffffff !important;
    font-weight: bold;
    cursor: default;
}
.sd-curr-n {
    display: inline-block;
    margin-left: 6px;
    padding: 0 7px;
    border-radius: 9px;
    background: rgba(0, 0, 0, .12);
    font-size: 11px;
}
.sd-curr-tab.is-on .sd-curr-n { background: rgba(255, 255, 255, .22); }
.sd-curr-note { color: #8a8a8a; font-size: 12px; }
.sd-curr-single { margin: -6px 0 16px; color: #7a4a00; font-size: 12px; font-weight: bold; }

.sd-home-legacy-head {
    margin: 4px 0 12px;
    font-size: 13px;
    color: #7a7a7a;
    font-weight: normal;
}
.sd-home-legacy { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 6px 0 18px; }
.sd-home-legacy-btn {
    margin: 0;
    padding: 7px 14px;
    background: #faf7f3;
    border: 1px solid #efe4d6;
    border-radius: 4px;
    color: #871619;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
}
.sd-home-legacy-btn:hover { background: #f4efe8 !important; color: #871619 !important; }
.sd-home-legacy-note { color: #8a8a8a; font-size: 12px; }

.sd-home-switch {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding-top: 16px;
    border-top: 1px solid #ececec;
    color: #7a7a7a;
    font-size: 13px;
}
.sd-home-switch-btn {
    margin: 0;
    padding: 6px 13px;
    background: #ffffff;
    border: 1px solid #dcdcdc;
    border-radius: 4px;
    color: #333333;
    font-size: 13px;
    cursor: pointer;
}
.sd-home-switch-btn:hover { border-color: #871619; color: #871619 !important; background: #ffffff !important; }

@media (max-width: 640px) {
    .sd-subject-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
    .sd-home-search input[type="search"] { width: 100%; }
}
