/* ND Roster - stylesheet
 * Colors live in the custom properties below; change them in one place.
 */

:root {
    color-scheme: light dark;

    --bg:            #e9e9f5;
    --text:          #222;
    --link:          #000088;

    --header-from:   #000088;  /* title bar gradient, top */
    --header-to:     #4949aa;  /* as close to the original #9999cf as the gold can stay readable on */
    --header-text:   #E7C773;
    --header-rule:   #666;

    --nav-bg:        #d8d8ed;
    --nav-border:    #999;

    --row-home:      #d8d8ed;  /* games at Notre Dame */
    --row-away:      #f1f1f1;
    --table-head:    #f7e78c;

    --muted:         #555;
    --win:           #1a6b2a;
    --loss:          #9b1c1c;
    --focus:         #000088;

    --font: Helvetica;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg:          #14141c;
        --text:        #e6e6ef;
        --link:        #9fb4ff;

        --header-from: #14143d;
        --header-to:   #262657;
        --header-rule: #444;

        --nav-bg:      #24243a;
        --nav-border:  #3d3d5c;

        --row-home:    #24243a;
        --row-away:    #1c1c26;
        --table-head:  #4a4327;

        --muted:       #a0a0b0;
        --win:         #6ee7a0;
        --loss:        #ff9a9a;
        --focus:       #9fb4ff;
    }
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: clamp(14px, 3.5vw, 17px);
    line-height: 1.4;
    margin: 0;
    padding: 0;
    -webkit-text-size-adjust: 100%;
}

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

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

[hidden] {
    display: none !important;
}


/* ---- header + navigation ---- */

/* The Back button is centred on the title bar only. Anchoring it to #header
   would make it drift as the menu below slides open and shut. */
.titlebar {
    position: relative;
}

#header h1 {
    margin: 0;
    padding: 0;
}

#header h1 a {
    background-image: linear-gradient(to bottom, var(--header-from), var(--header-to));
    border-bottom: 1px solid var(--header-rule);
    color: var(--header-text);
    display: block;
    font-size: clamp(20px, 5vw, 26px);
    font-weight: bold;
    padding: 14px 64px;   /* room for the Back button on either side */
    text-align: center;
    text-decoration: none;
    text-shadow: 0 1px 0 #000;
}

.titlebar #back {
    position: absolute;
    top: 50%;
    left: 8px;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    min-height: 44px;      /* comfortable tap target */
    padding: 0 14px;
    border-radius: 6px;
    background-color: rgb(255 255 255 / 0.15);
    border: 1px solid rgb(255 255 255 / 0.35);
    color: #fff;
    font-weight: bold;
    text-decoration: none;
    text-shadow: 0 -1px 0 rgb(0 0 0 / 0.6);
}

/* The menu slides shut when you pick a section and slides back on Back, the
   way the old jQuery slideToggle did. Overriding [hidden] keeps the element
   laid out so it has something to animate; visibility drops it from the tab
   order once the slide finishes. */
#nav {
    max-height: 500px;   /* taller than the menu itself (435px), never clips */
    opacity: 1;
    overflow: hidden;
    transition: max-height 300ms ease, opacity 200ms ease, visibility 0s;
}

#nav[hidden] {
    display: block !important;
    max-height: 0;
    opacity: 0;
    visibility: hidden;
    transition: max-height 300ms ease, opacity 200ms ease, visibility 0s 300ms;
}

#nav ul {
    list-style: none;
    margin: 10px;
    padding: 0;
}

#nav ul li a {
    background-color: var(--nav-bg);
    border: 1px solid var(--nav-border);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    margin-bottom: -1px;
    padding: 12px 10px;
    font-size: clamp(17px, 4.2vw, 19px);
    font-weight: bold;
    text-align: center;
    text-decoration: none;
}

#nav ul li:first-child a {
    border-radius: 8px 8px 0 0;
}

#nav ul li:last-child a {
    border-radius: 0 0 8px 8px;
}


/* ---- sections ---- */

/* Rosters run to 100+ rows, so sliding their height would be janky. Sections
   ease in on transform and opacity instead, which the compositor handles
   regardless of how tall the table is. */
@keyframes section-in {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.roster:not([hidden]) {
    animation: section-in 260ms ease-out;
}

/* Each section starts directly below the header, so scrolling to one would
   leave the title bar and Back button just above the fold. A scroll margin
   larger than any viewport makes the browser clamp to the very top instead. */
.roster {
    scroll-margin-top: 100vh;
}

.roster h2 {
    font-size: clamp(17px, 4.4vw, 21px);
    text-align: center;
    scroll-margin-top: 8px;
}

.empty,
#loading {
    color: var(--muted);
    text-align: center;
    padding: 20px 10px;
}

.backtotop {
    text-align: center;
    font-weight: bold;
}

.backtotop a {
    display: inline-block;
    min-height: 44px;
    line-height: 44px;
    padding: 0 16px;
}

#content {
    padding: 10px;
    text-align: center;
    color: var(--muted);
}


/* ---- tables ---- */

table {
    margin: auto;
    border-collapse: separate;
    border-spacing: 5px;
}

table.data {
    font-size: clamp(13px, 3.3vw, 16px);
}

table.data .num,
table.data .pos,
table.data .yr {
    text-align: center;
}

table.data.depth .name {
    text-align: left;
    line-height: 1.8;
}

table.data.depth .pos {
    font-weight: bold;
    vertical-align: top;
    white-space: nowrap;
    /* Match the stacked names' line-height so the label's first line box is
       the same height, and the two sit on a shared baseline. */
    line-height: 1.8;
}

/* Fixed-width slot so the stacked names line up under each other. */
.depth-num {
    display: inline-block;
    min-width: 2.2em;
    color: var(--muted);
}

table.schedule {
    width: 100%;
    font-size: clamp(11px, 2.8vw, 14px);
    border-spacing: 1px;
    text-align: center;
}

table.schedule th {
    background-color: var(--table-head);
    color: #222;
}

table.schedule .result {
    white-space: nowrap;
}

table.schedule .result.win {
    color: var(--win);
}

table.schedule .result.loss {
    color: var(--loss);
}

table.schedule tr.home td {
    background-color: var(--row-home);
}

table.schedule tr.away td {
    background-color: var(--row-away);
}

table.schedule td,
table.schedule th {
    padding: 6px 4px;
}

table.coaches {
    font-size: clamp(11px, 2.8vw, 14px);
    border-spacing: 3px;
}


/* ---- motion ---- */

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    #nav,
    #nav[hidden] {
        transition: none;
    }

    .roster:not([hidden]) {
        animation: none;
    }
}
