/* The settings menu (public/js/settings.js): the gear, the menu, the text
   size and motion choices, and the dev tools behind it. Loaded on every page,
   after the rest of the look. */

/* ---------------------------------------------------------------------------
   Text size and motion, as chosen in the menu
   --------------------------------------------------------------------------- */

/* Large text. Type, spacing and radii are all in rem, so this one number
   scales the page. Normal is 106.25%, set in base.css. */
html[data-text="large"] { font-size: 118.75%; }

/* Reduced motion: no hover lifts, no animation. The device's own
   reduce-motion setting gets the same, whatever the menu says. */
html[data-motion="reduced"] { scroll-behavior: auto; --card-lift: 0px; }
html[data-motion="reduced"] *,
html[data-motion="reduced"] *::before,
html[data-motion="reduced"] *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
}
html[data-motion="reduced"] :is(.btn-primary, .theme-toggle, .back-to-top):hover { transform: none; }
@media (prefers-reduced-motion: reduce) {
    :root { --card-lift: 0px; }
    :is(.btn-primary, .theme-toggle, .back-to-top):hover { transform: none; }
}

/* ---------------------------------------------------------------------------
   The gear. It wears the light/dark button's round style (.theme-toggle in
   base.css); only its drawing is its own.
   --------------------------------------------------------------------------- */

.settings-toggle .gear-teeth {
    stroke-width: 3.2;
    stroke-linecap: butt;   /* round ends would close the gaps between teeth */
}

/* The header spreads its items apart (space-between in base.css). With the
   gear there too, these keep the old look: the logo, the menu in the middle,
   and the two round buttons together on the right. */
.nav-container > .nav-menu,
.nav-container > .theme-toggle:not(.settings-toggle) { margin-left: auto; }

/* ---------------------------------------------------------------------------
   The menu, and the dev tools panel, which looks the same
   --------------------------------------------------------------------------- */

.settings-panel,
.dev-panel {
    position: fixed;
    z-index: 1100;
    width: min(380px, calc(100vw - 32px));
    max-height: min(80vh, 640px);
    overflow: auto;
    padding: var(--spacing-m);
    background: var(--menu-bg);
    border: 1px solid var(--menu-border);
    border-radius: var(--radius);
    color: var(--menu-text);
    box-shadow: var(--float-shadow);
    backdrop-filter: var(--glass-blur);
}

.settings-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-s);
}
.settings-head h2 { margin: 0; font-size: 1.15rem; }

.settings-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.6rem;
    line-height: 1;
    padding: 0 0.25rem;
    cursor: pointer;
}

.settings-panel fieldset {
    border: none;
    margin: var(--spacing-s) 0 0;
    padding: 0;
}
.settings-panel legend,
.settings-extra h3 {
    margin: 0 0 0.35rem;
    padding: 0;
    font-size: 0.9rem;
    font-weight: 600;
}

/* A row of choices, drawn as pills. The radio buttons stay in the page for
   keyboards and screen readers; only their circles are hidden. */
.settings-choice { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.settings-choice label {
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.85rem;
    border: 1px solid var(--menu-border);
    border-radius: 999px;
    font-size: 0.9rem;
    cursor: pointer;
}
.settings-choice input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.settings-choice label:has(input:checked) {
    background: var(--color-control-fill);
    border-color: var(--color-control-fill);
    color: var(--on-accent);
}
.settings-choice label:has(input:focus-visible) { outline: 2px solid var(--color-accent); outline-offset: 2px; }

.settings-extra { margin-top: var(--spacing-s); }
.settings-extra p {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin: 0.35rem 0;
    font-size: 0.9rem;
}

.settings-panel .btn,
.dev-panel .btn { padding: 0.35rem 0.8rem; font-size: 0.85rem; }

.settings-forget,
.settings-dev {
    margin-top: var(--spacing-m);
    padding-top: var(--spacing-s);
    border-top: 1px solid var(--menu-border);
}
.settings-forget p { margin: 0.5rem 0 0; font-size: 0.85rem; }
.settings-dev p { margin: 0 0 0.5rem; }

.settings-code {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    margin: var(--spacing-s) 0 0;
}
.settings-code[hidden] { display: none; }
.settings-code input,
.dev-filter {
    padding: 0.35rem 0.5rem;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 6px;
    color: inherit;
    font: inherit;
}
.settings-code input { display: block; width: 8rem; margin-top: 0.25rem; }

/* ---------------------------------------------------------------------------
   Dev mode
   --------------------------------------------------------------------------- */

.dev-badge {
    position: fixed;
    left: 16px;
    bottom: 16px;
    z-index: 1200;
    padding: 0.3rem 0.7rem;
    border: 2px solid var(--on-accent);
    border-radius: 999px;
    background: var(--color-control-fill);
    color: var(--on-accent);
    font: 700 0.8rem/1 var(--font-body);
    letter-spacing: 0.08em;
    cursor: pointer;
    box-shadow: var(--float-shadow);
}
.dev-badge[hidden] { display: none; }

.dev-panel {
    left: 16px;
    bottom: 60px;
    width: min(640px, calc(100vw - 32px));
    max-height: 70vh;
}
.dev-buttons { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: var(--spacing-s) 0; }
.dev-out { font-size: 0.85rem; }
.dev-out pre { white-space: pre-wrap; word-break: break-all; margin: 0; }
.dev-filter { width: 100%; margin: 0.25rem 0 0.5rem; }

.dev-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.dev-table th,
.dev-table td {
    padding: 0.25rem 0.4rem;
    border-bottom: 1px solid var(--menu-border);
    text-align: left;
    vertical-align: top;
}
.dev-table code { word-break: break-all; }
.dev-swatch {
    display: inline-block;
    width: 0.9rem;
    height: 0.9rem;
    margin-right: 0.35rem;
    border: 1px solid var(--menu-border);
    border-radius: 3px;
    vertical-align: middle;
}
.dev-bad { color: var(--color-accent); }

/* Text the contrast check found too faint. */
.dev-flag { outline: 2px dashed #FF00D4 !important; outline-offset: 2px; }

/* The layout grid: an 8 px baseline over the whole screen, and the page
   column split in 12 with 16 px gutters. */
.dev-grid {
    position: fixed;
    inset: 0;
    z-index: 1050;
    pointer-events: none;
    background-image: repeating-linear-gradient(to bottom, rgba(0, 160, 255, 0.16) 0 1px, transparent 1px 8px);
}
.dev-grid::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: var(--grid-left, 16px);
    width: var(--grid-width, calc(100% - 32px));
    outline: 1px solid rgba(255, 0, 80, 0.5);
    background-image: repeating-linear-gradient(to right,
        rgba(255, 0, 80, 0.1) 0 calc(100% / 12 - 16px), transparent calc(100% / 12 - 16px) calc(100% / 12));
}

/* Product and variant ids, on the cards (dev tools, IDs). */
.dev-ids [data-dev-id] { position: relative; }
.dev-ids [data-dev-id]::after {
    content: attr(data-dev-id);
    position: absolute;
    left: 8px;
    bottom: 8px;
    z-index: 2;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.8);
    color: #FFFFFF;
    font: 0.7rem/1.2 ui-monospace, monospace;
    pointer-events: none;
}
