/* ==================================================================
   Wyndham — Reset and base elements
   ================================================================== */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    height: 100%;
    /* Never let the page itself bounce; scrolling belongs to panes. */
    overscroll-behavior-y: none;
}

body {
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: var(--size-base);
    line-height: var(--leading-normal);
    letter-spacing: var(--tracking-normal);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-synthesis-weight: none;

    /* This is an application, not a document: the chrome should not be
       selectable or long-pressable. Selection is switched back on for
       book text, inputs, and anywhere copying is the point. */
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

/* Anywhere the reader may legitimately want to copy. */
input, textarea, [contenteditable="true"],
.selectable, .book-text, .reader-surface, .prose, .code {
    -webkit-user-select: text;
    user-select: text;
    -webkit-touch-callout: default;
}

/* --- Media -------------------------------------------------------- */

img, svg, video, canvas {
    display: block;
    max-width: 100%;
}

img {
    height: auto;
    -webkit-user-drag: none;
}

/* --- Typography --------------------------------------------------- */

h1, h2, h3, h4, h5, h6 {
    font-weight: var(--weight-semibold);
    line-height: var(--leading-tight);
    letter-spacing: var(--tracking-tight);
    text-wrap: balance;
}

h1 { font-size: var(--size-2xl); }
h2 { font-size: var(--size-xl); }
h3 { font-size: var(--size-lg); }
h4 { font-size: var(--size-md); letter-spacing: var(--tracking-snug); }
h5, h6 { font-size: var(--size-base); letter-spacing: var(--tracking-snug); }

p { text-wrap: pretty; }

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--duration-fast) var(--ease);
}

a:hover { color: var(--accent-hover); }

/* Underline links inside running prose, where they need to be obvious. */
.prose a {
    text-decoration: underline;
    text-underline-offset: 0.16em;
    text-decoration-thickness: 1px;
    text-decoration-color: var(--accent-line);
}

.prose a:hover { text-decoration-color: var(--accent); }

strong, b { font-weight: var(--weight-semibold); }

small { font-size: var(--size-sm); }

code, kbd, pre, samp {
    font-family: var(--font-mono);
    font-size: 0.92em;
}

hr {
    border: 0;
    border-top: 1px solid var(--line);
    margin: var(--space-6) 0;
}

::selection {
    background: var(--accent-soft);
    color: var(--text);
}

/* --- Forms -------------------------------------------------------- */

input, button, textarea, select {
    font: inherit;
    color: inherit;
    background: none;
    border: none;
    letter-spacing: inherit;
}

button {
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

button:disabled { cursor: not-allowed; }

textarea {
    resize: vertical;
    min-height: 88px;
}

/* Consistent, visible focus that only appears for keyboard users. */
:focus { outline: none; }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--radius-xs);
}

/* --- Scrollbars ---------------------------------------------------
   Slim and unobtrusive on desktop; untouched on iOS, which already
   overlays them.                                                    */

@media (pointer: fine) {
    * {
        scrollbar-width: thin;
        scrollbar-color: var(--line-strong) transparent;
    }

    *::-webkit-scrollbar { width: 10px; height: 10px; }
    *::-webkit-scrollbar-track { background: transparent; }

    *::-webkit-scrollbar-thumb {
        background: var(--line-strong);
        border-radius: var(--radius-full);
        border: 3px solid transparent;
        background-clip: content-box;
    }

    *::-webkit-scrollbar-thumb:hover { background-color: var(--text-3); background-clip: content-box; }
}

/* --- Accessibility helpers ---------------------------------------- */

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    top: var(--space-2);
    left: var(--space-2);
    z-index: 200;
    padding: var(--space-2) var(--space-4);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    transform: translateY(-200%);
    transition: transform var(--duration-base) var(--ease);
}

.skip-link:focus-visible { transform: translateY(0); }

[hidden] { display: none !important; }

/* --- Touch behaviour ---------------------------------------------- */

@media (hover: none) {
    /* Hover styles are meaningless on touch and leave elements stuck in
       a hovered state after a tap. */
    *:hover { transition: none; }
}
