/* ==========================================================================
   Appearance & settings — pages/settings.js
   Tokens only. The theme previews deliberately declare no colours of their
   own: each one carries data-theme, so the six palettes in study.css draw
   themselves.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Layout: sticky section nav + one readable column
   -------------------------------------------------------------------------- */
.st-set-page { max-width: 1120px; }

.st-set-layout {
    display: grid;
    grid-template-columns: 200px minmax(0, 1fr);
    gap: 32px;
    align-items: start;
}

.st-set-nav {
    position: sticky;
    top: 24px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.st-set-nav .st-eyebrow { padding: 0 12px 8px; }
.st-set-nav__link {
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--st-ink-2);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.3;
}
.st-set-nav__link:hover { background: var(--st-fill); color: var(--st-ink); }
.st-set-nav__link[aria-current="true"] { background: var(--st-fill); color: var(--st-ink); font-weight: 700; }

.st-set-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 840px;
    min-width: 0;
}

.st-set-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
    /* Clears the sticky nav when a section link scrolls you here. */
    scroll-margin-top: 24px;
}
/* The section takes focus after a nav jump; the heading below is the cue. */
.st-set-section:focus { outline: none; }
.st-set-section__head { display: flex; flex-direction: column; gap: 4px; }
.st-set-section__title { font-size: 20px; line-height: 1.2; }
.st-set-section__sub { font-size: 14px; color: var(--st-ink-2); }

/* --------------------------------------------------------------------------
   Theme picker
   -------------------------------------------------------------------------- */
.st-set-themes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
}

.st-set-theme {
    display: flex;
    flex-direction: column;
    gap: 9px;
    padding: 9px;
    border: 2px solid var(--st-border-soft);
    border-radius: 14px;
    background: var(--st-surface);
    color: var(--st-ink);
    text-align: left;
    cursor: pointer;
}
.st-set-theme:hover { border-color: var(--st-border-strong); }
.st-set-theme[aria-checked="true"] {
    border-color: var(--st-accent);
    box-shadow: 0 0 0 3px var(--st-accent-soft);
}
.st-set-theme__name {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0 2px;
    font-size: 13px;
    font-weight: 700;
}
.st-set-theme__check { color: var(--st-accent); visibility: hidden; }
.st-set-theme[aria-checked="true"] .st-set-theme__check { visibility: visible; }

.st-set-caption {
    font-size: 13px;
    color: var(--st-ink-2);
    line-height: 1.5;
}
.st-set-caption strong { color: var(--st-ink); }

/* --------------------------------------------------------------------------
   Theme mini-preview — a 1:8 sketch of the app drawn by the theme's own
   tokens. Sizes are fixed; every colour, radius, shadow and font is inherited
   from the data-theme on the wrapper.
   -------------------------------------------------------------------------- */
.st-set-mini {
    display: flex;
    width: 100%;
    aspect-ratio: 8 / 5;
    overflow: hidden;
    border: 1px solid var(--st-border);
    border-radius: 10px;
    background: var(--st-bg);
}

.st-set-mini__side {
    flex: 0 0 26%;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 7px 6px;
    background: var(--st-surface-2);
    border-right: 1px solid var(--st-border-soft);
}
.st-set-mini__logo { display: flex; align-items: flex-end; gap: 2px; margin-bottom: 3px; }
.st-set-mini__logo i { display: block; border-radius: 50%; }
.st-set-mini__logo i:nth-child(1) { width: 3px; height: 3px; background: var(--st-dot-1); }
.st-set-mini__logo i:nth-child(2) { width: 4px; height: 4px; background: var(--st-dot-2); }
.st-set-mini__logo i:nth-child(3) { width: 5px; height: 5px; background: var(--st-dot-3); }
.st-set-mini__nav {
    display: block;
    width: 74%;
    height: 3px;
    border-radius: 2px;
    background: var(--st-border-strong);
}
.st-set-mini__nav.is-active {
    width: 100%;
    height: 9px;
    border-radius: 3px;
    background: var(--st-fill);
}

.st-set-mini__body {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 7px;
    min-width: 0;
}
.st-set-mini__hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 0 7px;
    height: 30px;
    border-radius: 7px;
    background-color: var(--st-hero-bg);
    background-image: var(--st-hero-pattern);
    background-size: 7px 7px;
    color: var(--st-hero-fg);
}
.st-set-mini__glyph {
    font-family: var(--st-font-display);
    font-weight: var(--st-display-weight);
    font-size: 13px;
    line-height: 1;
    letter-spacing: -0.02em;
}
.st-set-mini__hero-btn {
    display: block;
    flex: 0 0 auto;
    width: 22px;
    height: 9px;
    border-radius: var(--st-radius-btn);
    background: var(--st-hero-btn-bg);
}

.st-set-mini__cards { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.st-set-mini__card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 6px;
    background: var(--st-surface);
    border: var(--st-card-border-w) solid var(--st-border);
    border-radius: 7px;
    box-shadow: var(--st-shadow-card);
}
.st-set-mini__bar { display: block; height: 3px; border-radius: 2px; background: var(--st-ink-4); }
.st-set-mini__bar--short { width: 55%; background: var(--st-border-strong); }
/* One accent stroke so the theme's primary colour is visible at this size. */
.st-set-mini__card:first-child .st-set-mini__bar:first-child { background: var(--st-accent); }

.st-set-mini__chip {
    position: relative;
    display: block;
    width: 34px;
    height: 9px;
    border-radius: 999px;
    background: var(--st-warm-soft);
}
/* The second chip tone, without a second element in the markup. */
.st-set-mini__chip::after {
    content: "";
    position: absolute;
    left: 38px;
    top: 0;
    width: 22px;
    height: 9px;
    border-radius: 999px;
    background: var(--st-green-soft);
}

/* --------------------------------------------------------------------------
   Switch + preference rows
   -------------------------------------------------------------------------- */
.st-set-rows { display: flex; flex-direction: column; }
.st-set-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 14px 0;
    border-top: 1px solid var(--st-border-soft);
}
.st-set-row__text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.st-set-row__text strong { font-size: 14px; font-weight: 700; }
.st-set-row__help {
    font-size: 13px;
    color: var(--st-ink-2);
    line-height: 1.45;
    max-width: 56ch;
}

.st-set-switch {
    position: relative;
    flex: 0 0 auto;
    width: 46px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--st-border-strong);
    border-radius: 999px;
    background: var(--st-fill);
    transition: background-color 0.16s ease, border-color 0.16s ease;
}
/* Keeps the tap target at 44px without a 44px-tall track. */
.st-set-switch::before { content: ""; position: absolute; inset: -8px -6px; }
.st-set-switch__thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--st-surface);
    box-shadow: 0 1px 2px var(--st-shadow-tint);
    transition: transform 0.16s ease, background-color 0.16s ease;
}
.st-set-switch[aria-checked="true"] { background: var(--st-accent); border-color: var(--st-accent); }
.st-set-switch[aria-checked="true"] .st-set-switch__thumb {
    transform: translateX(18px);
    background: var(--st-on-accent);
}

.st-set-prefs { display: flex; flex-direction: column; gap: 20px; }
.st-set-pref { display: flex; flex-direction: column; gap: 10px; }
.st-set-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.st-set-chip { min-height: 38px; padding: 6px 14px; font-size: 13px; }

/* --------------------------------------------------------------------------
   Account + data
   -------------------------------------------------------------------------- */
.st-set-account { display: flex; align-items: center; gap: 14px; }
.st-set-account__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.st-set-account__text strong { font-size: 16px; font-weight: 700; }
.st-set-account__text span { font-size: 14px; }

.st-set-note {
    font-size: 14px;
    color: var(--st-ink-2);
    line-height: 1.55;
    max-width: 64ch;
}

.st-set-data { display: flex; flex-direction: column; gap: 16px; }

/* Board sync: the one place that says how much of the account is loaded. */
.st-set-sync {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    flex-wrap: wrap;
    padding: 14px 16px;
    border: 1px solid var(--st-border);
    border-radius: var(--st-radius-card-sm);
    background: var(--st-surface-2);
}
.st-set-sync__text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.st-set-sync__text .st-cluster { align-items: center; gap: 8px; }
.st-set-sync__text strong { font-size: 14px; font-weight: 700; }

/* The demo banner sits above every other section, so it spans the column. */
.st-set-demo {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    line-height: 1.45;
}
.st-set-demo__text { flex: 1 1 auto; font-weight: 600; }

/* --------------------------------------------------------------------------
   Reduce motion. Global on purpose: the toggle lives on this page but has to
   damp the whole of /study, and <html> is where settings.js writes it.
   -------------------------------------------------------------------------- */
html[data-reduce-motion="true"] *,
html[data-reduce-motion="true"] *::before,
html[data-reduce-motion="true"] *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
}
html[data-reduce-motion="true"] .st-card--link:hover,
html[data-reduce-motion="true"] .st-btn:hover { transform: none; }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1100px) {
    .st-set-layout { grid-template-columns: 176px minmax(0, 1fr); gap: 24px; }
}

@media (max-width: 900px) {
    /* The nav collapses above the content and scrolls sideways. */
    .st-set-layout { grid-template-columns: minmax(0, 1fr); gap: 18px; }
    .st-set-nav {
        top: 0;
        z-index: 6;
        flex-direction: row;
        gap: 6px;
        overflow-x: auto;
        scrollbar-width: none;
        padding: 8px 0;
        background: var(--st-bg);
        border-bottom: 1px solid var(--st-border-soft);
    }
    .st-set-nav::-webkit-scrollbar { display: none; }
    .st-set-nav .st-eyebrow { display: none; }
    .st-set-nav__link { white-space: nowrap; }
    .st-set-section { scroll-margin-top: 72px; }
    .st-set-themes { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
}

@media (max-width: 760px) {
    .st-set-row { align-items: flex-start; gap: 12px; }
    .st-set-sync { flex-direction: column; }
    .st-set-sync .st-btn { width: 100%; justify-content: center; }
    .st-set-demo { align-items: flex-start; flex-wrap: wrap; }
    .st-set-switch { margin-top: 2px; }
    .st-set-section { scroll-margin-top: 108px; }
}
