/* ========== Font ========== */
@font-face {
    font-family: "Quicksand";
    src: url("../fonts/Quicksand-Regular.woff2") format("woff2"),
        url("../fonts/Quicksand-Regular.woff") format("woff");
    font-display: swap;
}

/* ========== Base ========== */
*,
*::before,
*::after {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100dvh;
    font-family: "Quicksand", system-ui, sans-serif;
    font-weight: 700;
    color: var(--text-primary);
    background-color: var(--bg-color-1);
    background-image: var(--gradient-bg);
    background-attachment: fixed;
    /* viewport-fit=cover: keep content clear of notches and system bars */
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

button,
input,
textarea {
    font: inherit;
}

h1,
h2,
h3,
h4,
p {
    margin: 0;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

input,
textarea,
button,
.card,
.course-card {
    transition: background-color 200ms ease, color 200ms ease, border-color 200ms ease,
        box-shadow 200ms ease, opacity 200ms ease;
}

/* ========== Page layout ========== */
.app {
    width: min(1200px, 100%);
    margin: 0 auto;
    padding: 16px;
}

.topbar {
    display: grid;
    grid-template-columns: 40px 1fr 40px;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.titles {
    text-align: center;
}

h1 {
    font-size: 1.5rem;
}

.lead {
    color: var(--muted);
    font-size: 13px;
    margin-top: 4px;
}

/* One column on phones/tablets, two columns (account | courses) on wide screens */
.layout {
    display: grid;
    gap: 20px;
    grid-template-columns: 1fr;
}

@media (min-width: 900px) {
    .layout {
        grid-template-columns: minmax(320px, 420px) 1fr;
        align-items: start;
    }

    .account {
        position: sticky;
        top: 16px;
    }
}

/* Below 900px the cards stack; the email card is capped at 500px and centered */
@media (max-width: 900px) {
    .account {
        width: 100%;
        max-width: 460px;
        margin-inline: auto;
    }
}

.card {
    background: var(--card);
    border-radius: 14px;
    padding: 24px;
    box-shadow: 0 8px 30px var(--shadow-dark);
}

h2 {
    font-size: 1.1rem;
    margin-bottom: 4px;
}

h3 {
    font-size: 1rem;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.badge {
    padding: 4px 12px;
    border-radius: 999px;
    background: var(--bg-light-2);
    border: 1px solid var(--border-light-3);
    font-size: 13px;
}

.form-title {
    margin-top: 18px;
}

.list-title {
    margin-top: 24px;
}

.hint {
    color: var(--muted);
    font-size: 13px;
    margin-top: 6px;
}

/* Courses panel is dimmed and non-interactive (via the `inert` attribute) until verification */
.courses.locked> :not(.panel-head):not(.hint) {
    opacity: 0.45;
}

.courses:not(.locked) #lockHint {
    display: none;
}

/* ========== Forms and buttons ========== */
label {
    display: block;
    font-size: 13px;
    color: var(--muted);
    margin: 14px 0 6px;
}

input[type="text"],
textarea {
    width: 100%;
    font-size: 16px;
    /* 16px stops iOS zooming on focus */
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid var(--border-light-3);
    background: var(--bg-light);
    color: inherit;
}

input:disabled {
    opacity: 0.6;
}

input::placeholder,
textarea::placeholder {
    font-size: 0.87em;
    opacity: 0.75;
}

textarea {
    resize: vertical;
    min-height: 96px;
    line-height: 1.5;
    font-size: 15px;
}

.btn {
    width: 100%;
    height: 44px;
    padding: 0 16px;
    margin-top: 10px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: var(--gradient-button);
    color: var(--text-white);
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 6px 18px var(--shadow-accent);
}

.btn:hover:not(:disabled) {
    opacity: 0.9;
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn.ghost {
    background: transparent;
    border-color: var(--border-light-3);
    color: var(--text-primary);
    box-shadow: none;
}

.btn.danger {
    background: transparent;
    border-color: var(--error-red);
    color: var(--error-red);
    box-shadow: none;
}

.btn-row {
    display: flex;
    gap: 8px;
}

.btn-row .btn {
    margin-top: 10px;
}

/* Input and its button share a row and wrap onto two lines only when they don't fit (no breakpoint) */
.field-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.field-row input {
    flex: 3 1 180px;
    min-width: 0;
}

.field-row .btn {
    flex: 1 1 150px;
    width: auto;
    margin-top: 0;
    height: 46px;
}

.mode-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 8px;
}

.mode-row .hint {
    margin: 0;
    color: var(--highlight);
}

.link-btn {
    background: none;
    border: 0;
    padding: 4px;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
}

.link-btn:hover {
    color: var(--accent);
}

.icon-btn {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
}

.icon-btn:hover {
    background: var(--accent-2);
}

.icon-btn img {
    width: 22px;
    height: 22px;
    filter: invert();
}

.message {
    min-height: 1.3em;
    margin-top: 10px;
    text-align: center;
    font-size: 0.9rem;
}

.message.error {
    color: var(--error-red);
}

.message.success {
    color: var(--success-green);
}

/* ========== Course cards ========== */
.course-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    border: 1px solid var(--border-light-2);
    border-radius: 12px;
    background: var(--bg-light);
    font-size: 14px;
}

.course-card.preview {
    margin-top: 8px;
    border-style: dashed;
}

.course-card.is-replacing {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent);
}

.course-name {
    font-size: 1rem;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.course-card dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 14px;
    margin: 0;
}

.course-card dt {
    color: var(--muted);
}

.course-card dd {
    margin: 0;
    text-align: right;
}

.course-card dd.ok {
    color: var(--success-green);
}

.course-card .actions {
    display: flex;
    gap: 8px;
    margin-top: auto;
}

.course-card .actions .btn {
    margin: 0;
    height: 38px;
    font-size: 14px;
}

/* Cards flow into as many columns as fit: 1 on phones, 2-3 on wide screens */
.course-grid {
    display: grid;
    gap: 12px;
    margin-top: 10px;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
}

/* ========== Footer ========== */
.footer-links {
    display: flex;
    justify-content: center;
    gap: 28px;
    margin-top: 20px;
}

.footer-links a {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.ext-icon {
    width: 1em;
    height: 1em;
    background-color: currentColor;
    -webkit-mask: url("/static/icons/external-link.svg") center / contain no-repeat;
    mask: url("/static/icons/external-link.svg") center / contain no-repeat;
}

/* ========== Modals ========== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    background: rgba(0, 0, 0, 0.6);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 250ms ease, visibility 250ms ease;
}

.modal.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 640px;
    max-height: 85dvh;
    overflow: auto;
    padding: 24px;
    border-radius: 10px;
    background: var(--card);
    box-shadow: 0 8px 30px var(--shadow-dark);
    transform: scale(0.96);
    opacity: 0;
    transition: transform 250ms ease, opacity 250ms ease;
}

.modal.open .modal-content {
    transform: scale(1);
    opacity: 1;
}

.modal-content h2 {
    margin: 0 28px 10px 0;
}

.modal-content h2:not(:first-child) {
    margin-top: 20px;
}

.modal-content h4 {
    margin: 16px 0 6px;
}

.modal-content p {
    margin: 6px 0;
}

.modal-content ul,
.modal-content ol {
    margin: 6px 0;
    padding-left: 22px;
}

.modal-content .notes {
    color: var(--muted);
    font-size: 14px;
}

.modal-close {
    position: absolute;
    top: 8px;
    right: 10px;
    padding: 4px 10px;
    border: 0;
    background: none;
    color: var(--muted);
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
}

.modal-close:hover {
    color: var(--text-primary);
}

.feedback-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.feedback-actions .hint {
    margin: 0;
}

.feedback-actions .message {
    flex: 1;
    margin: 0;
    min-height: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#fbSendBtn {
    width: auto;
    min-width: 120px;
    height: 36px;
    margin: 0;
}

#notesTitle,
#helpTitle {
    margin-top: 0px;
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }
}

/* make sure the `hidden` attribute always wins over component display rules */
[hidden] {
    display: none !important;
}

/* "Remember me" checkbox row */
.check {
    display: grid;
    grid-template-columns: 1.5em auto;
    align-items: center;
    gap: 0.5em;
    margin-top: 1rem;
    font-size: 0.9rem;
    cursor: not-allowed;
}

.check input[type="checkbox"] {
    appearance: none;
    background-color: #fff;
    margin: 0;
    font: inherit;
    color: currentColor;
    width: 1.15em;
    height: 1.15em;
    border: 0.15em solid currentColor;
    border-radius: 0.2rem;

    display: grid;
    place-content: center;

    background-color: transparent;
    accent-color: transparent;
}

.check input[type="checkbox"]::before {
    content: "";
    width: 0.65em;
    height: 0.65em;
    transform: scale(0);
    transition: 120ms transform ease-in-out;
    box-shadow: inset 1em 1em var(--accent);
}

.check input[type="checkbox"]:checked::before {
    transform: scale(1);
}

#remember {
    margin-left: 0.4rem;
}

#remember:disabled {
    color: var(--accent);
    cursor: not-allowed;
}

#logoutBtn {
    margin-top: 0.5rem;
}

#code:disabled,
#email:disabled {
    cursor: not-allowed;
}

:root {
    --chevron-collapsed: -90deg;
    --chevron-expanded: 0deg;
}

/* ---- the two tracking sections ------------------------------------------------------ */
.tracker {
    padding: 0.25rem 0;
}

.tracker+.tracker {
    border-top: 1px solid var(--border, rgba(127, 127, 127, 0.25));
    margin-top: 0.5rem;
    padding-top: 0.5rem;
}

.tracker-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tracker-heading {
    margin: 0;
    font-size: inherit;
    min-width: 0;
}

.tracker-head .badge:last-child {
    margin-left: auto;
}

/* the 0/4 and 0/10 counters sit on the right */
.tracker-blurb {
    margin: 0.25rem 0 0.75rem;
}

/* ---- "New!" pill: same pill as the counter, accent colour ----------------------------- */
.badge-new {
    background: var(--accent, #2b6cb0);
    color: var(--on-accent, #fff);
    border-color: transparent;
    font-weight: 700;
}

/* ---- collapsible: toggle button with rotating chevron --------------------------------- */
.collapsible-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.25rem;
    background: none;
    border: 0;
    color: inherit;
    font: inherit;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

.collapsible-toggle:focus-visible {
    outline: 2px solid var(--accent, #2b6cb0);
    outline-offset: 2px;
    border-radius: 6px;
}

.chevron {
    width: 1.5rem;
    height: 1.5rem;
    flex: none;
    transform: rotate(var(--chevron-collapsed));
    transition: transform 0.25s ease;
}

.collapsible.is-open .chevron {
    transform: rotate(var(--chevron-expanded));
}

/* Optional: the PNG is a single colour. If it is dark and disappears on the dark theme: */
[data-theme="dark"] .chevron {
    filter: invert(1);
}

/* ---- collapsible: animated height (0fr -> 1fr needs no JS measuring) ------------------ */
.collapsible-body {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.25s ease;
}

.collapsible.is-open .collapsible-body {
    grid-template-rows: 1fr;
}

.collapsible-inner {
    min-height: 0;
    overflow: hidden;
    padding: 0 4px;
    /* room for focus outlines, which overflow:hidden would clip */
    margin: 0 -4px;
}

@media (prefers-reduced-motion: reduce) {

    .chevron,
    .collapsible-body {
        transition: none;
    }
}

/* ---- schedule lines on course cards ---------------------------------------------------- */
.course-card .meeting {
    display: block;
}

/* #coursesTitle {
    margin-bottom: 10px;
} */

#profTracker {
    padding-bottom: 0px;
}