/* ── Design Tokens ─────────────────────────────────── */
:root {
    --bg: #0c1316;
    --surface: #1d222b;
    --surface2: #394258;
    --border: #2a3347;
    --accent: #50c5bb;
    --accent2: #f0b429;
    --text: #d8e9ff;
    --text-muted: #d9dbde;
    --text-menu: #212123;
    --code-bg: #111827;
    --tinthighlight: #42c7bc;
    --radius: 10px;
    --font-body: 'DM Sans', sans-serif;
    --font-mono: 'Space Mono', monospace;
    --transition: 0.2s ease;
}

a {
    color: #f2429f;
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: #b83fc9;
}

/* Link conventions (prose links only):
   - external (target=_blank): solid underline on hover + small arrow-out icon
   - same-page (#anchor): dotted underline, no icon */
.copy a[target="_blank"]::after,
td a[target="_blank"]::after,
footer a[target="_blank"]::after {
    content: "";
    display: inline-block;
    width: 0.7em;
    height: 0.7em;
    margin-left: 0.25em;
    vertical-align: -0.05em;
    background-color: currentColor;
    opacity: 0.8;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 3H3v10h10v-3M9 2h5v5M14 2L7 9'/%3E%3C/svg%3E") center / contain no-repeat;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 3H3v10h10v-3M9 2h5v5M14 2L7 9'/%3E%3C/svg%3E") center / contain no-repeat;
}
.copy a[target="_blank"]:hover,
td a[target="_blank"]:hover {
    text-decoration: underline;
}
.copy a[href^="#"],
td a[href^="#"] {
    text-decoration: underline dotted;
    text-underline-offset: 3px;
}

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

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 18px;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* ── Layout ─────────────────────────────────────────── */
#index {
    max-width: 1800px;
    margin: 0 auto;
    padding: 0 24px;
}

.container {
    width: 100%;
}

/* ── Skip to content link ────────────────────────────── */
.skip-link {
    position: absolute;
    top: -100%;
    left: 24px;
    z-index: 1000;
    padding: 10px 20px;
    background: var(--accent);
    color: #000;
    font-weight: 600;
    font-size: 0.9rem;
    border-radius: 0 0 var(--radius) var(--radius);
    text-decoration: none;
    transition: top 0.15s;
}

.skip-link:focus {
    top: 0;
}

/* ── Header / Nav ────────────────────────────────────── */
#menu {
    position: sticky;
    top: 0;
    z-index: 500;
    background: rgba(13, 17, 23, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
}

.nav-inner {
    max-width: 1800px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}

.nav-logo {
    width: 146px;
    height: 46px;
    background-image: url('../images/ease360-logo-accent.png');
    background-size: cover;
}

.nav-links {
    display: flex;
    gap: 28px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 1.15rem;
    font-weight: 500;
    transition: color var(--transition);
}

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

.nav-links>li {
    position: relative;
}

.dropdown-arrow {
    font-size: 0.7em;
    margin-left: 3px;
    vertical-align: middle;
    display: inline-block;
    transition: transform var(--transition);
}

.has-dropdown:hover .dropdown-arrow,
.has-dropdown:focus-within .dropdown-arrow {
    transform: rotate(180deg);
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--tinthighlight);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 0 6px;
    min-width: 260px;
    white-space: nowrap;
    list-style: none;
    margin: 0;
    z-index: 400;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.has-dropdown:hover .dropdown-menu,
.has-dropdown:focus-within .dropdown-menu {
    display: block;
}

.dropdown-menu li a {
    display: block;
    padding: 9px 18px;
    color: var(--text-menu);
    font-size: 0.875rem;
    font-weight: 500;
    transition: color var(--transition), background var(--transition);
}

.dropdown-menu li a:hover {
    color: var(--text);
    background: rgba(80, 197, 187, 0.07);
}

/*
 * ── Z-INDEX SCALE ─────────────────────────────────────────────────────────────
 * 1000  full-screen viewer     — covers everything, including the nav
 *  900  mobile nav menu        — highest UI element on mobile
 *  500  sticky nav bar         — always above page content
 *  400  desktop dropdown menu  — below nav bar, above everything else
 *  300  loading overlay        — above canvas, below nav
 *  100  controllers / overlays — above canvas
 *    2  snapshot canvas (ex4)  — just above live canvas during crossfade
 *    0  loading when hidden
 * ─────────────────────────────────────────────────────────────────────────────
 */
#ease360Layout {
    position: relative;
    width: 100%;
    margin: 0;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--surface);
}

#myEase360 {
    width: 100%;
    height: 480px;
    background-color: #0f1520;
    position: relative;
    z-index: 100;
}

/* ── Full screen toggle ──────────────────────────────── */
.expand-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 350;
    width: 38px;
    height: 38px;
    padding: 0;
    display: grid;
    place-items: center;
    color: #fff;
    background: rgba(13, 17, 23, 0.62);
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 8px;
    cursor: pointer;
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    transition: border-color var(--transition), background var(--transition);
}

.expand-btn:hover {
    border-color: var(--accent);
    background: rgba(13, 17, 23, 0.82);
}

.expand-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.expand-btn svg {
    width: 18px;
    height: 18px;
    display: block;
}

/* Left / right chevrons: click to turn the viewer a little */
.chev-btn {
    position: absolute;
    top: 50%;
    z-index: 350;
    width: 72px;
    height: 72px;
    margin-top: -36px;
    padding: 0;
    display: grid;
    place-items: center;
    color: #fff;
    background: rgba(13, 17, 23, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 50%;
    cursor: pointer;
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    transition: border-color var(--transition), background var(--transition);
}

.chev-left  { left: 12px; }
.chev-right { right: 12px; }

.chev-btn:hover {
    /* border-color: var(--accent); */
    background: rgba(13, 17, 23, 0.75);
}

.chev-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* no ring on the viewer itself when it takes arrow keys */
#myEase360:focus,
#myEase360:focus-visible {
    outline: none;
}

.chev-btn svg {
    width: 40px;
    height: 40px;
    display: block;
}

.expand-btn .ico-in,
#ease360Layout.is-fs .expand-btn .ico-out {
    display: none;
}

#ease360Layout.is-fs .expand-btn .ico-in {
    display: block;
}

/* Full screen shows the whole 16:9 frame, uncropped. The viewer is the largest
   16:9 box that fits the screen; ease360 re-measures on the resize event. */
#ease360Layout.is-fs,
#ease360Layout:fullscreen {
    position: fixed;
    inset: 0;
    z-index: 1000;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}

#ease360Layout.is-fs #myEase360,
#ease360Layout:fullscreen #myEase360 {
    flex: none;
    width: min(100vw, calc(100vh * 16 / 9));
    height: min(100vh, calc(100vw * 9 / 16));
    overflow: hidden;
}

@supports (height: 100dvh) {
    #ease360Layout.is-fs #myEase360,
    #ease360Layout:fullscreen #myEase360 {
        width: min(100vw, calc(100dvh * 16 / 9));
        height: min(100dvh, calc(100vw * 9 / 16));
    }
}

/* ── What you'll learn list ───────────────────────────────── */
/* ── Canvas opacity transition ───────────────────────────
   NOTE: #myEase360 canvas opacity/transition styles are
   intentionally NOT global. They are introduced in Example 4
   (Change Color) where crossfading is first explained.
   Each example page that needs them includes them inline.
   ──────────────────────────────────────────────────────── */

/* ── Instructions overlay ────────────────────────────── */
#ease360Layout h3.instructions {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 400;
    letter-spacing: 0.08em;
    color: rgb(30 37 53);
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    background: rgb(66 199 188);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(80, 197, 187, 0.25);
    border-radius: 20px;
    padding: 8px 20px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 1s ease;
    white-space: nowrap;
}

#ease360Layout h3.instructions.opacity1 {
    opacity: 1;
}

/* ── Loading ─────────────────────────────────────────── */
.loading {
    position: absolute;
    z-index: 300;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    opacity: 1;
    pointer-events: none;
    transition: opacity 0.6s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

.loading.opacity0 {
    opacity: 0;
}

.loading h4 {
    font-family: var(--font-mono);
    font-size: 1rem;
    letter-spacing: 0.15em;
    color: var(--accent);
    text-align: center;
    margin: 0;
    text-transform: uppercase;
}

/* ── Controls bar ────────────────────────────────────── */
.viewer-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    background: var(--surface2);
}

.viewer-controls-label {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.goto-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.goto-buttons button {
    font-family: var(--font-mono);
    font-size: 1.0rem;
    padding: 6px 14px;
    background-color: #0d1117;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background-color 0.15s;
    white-space: nowrap;
    outline: none;
    /* removed via :focus-visible below */
}

.goto-buttons button:hover {
    border-color: var(--accent);
    color: var(--accent);
    background-color: rgba(80, 197, 187, 0.08);
}

.goto-buttons button:focus:not(:focus-visible),
.goto-buttons button:active {
    outline: none;
    border-color: var(--border);
    color: var(--text-muted);
    background-color: #0d1117;
}

.goto-buttons button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-color: var(--accent);
}

.goto-buttons a {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    padding: 6px 14px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    text-decoration: none;
    transition: all var(--transition);
    white-space: nowrap;
}

.goto-buttons a:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(80, 197, 187, 0.08);
}

/* ── Docs section ────────────────────────────────────── */
#controls {
    margin: 0;
}

/* ── h1 (example page titles) ───────────────────────── */
h1 {
    font-size: 2.2rem;
    color: var(--text);
    margin: 0 0 12px;
    letter-spacing: -0.02em;
}

/* ── Example info bar (callbacks display) ───────────── */
.example-info {
    display: flex;
    gap: 20px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

/* ── Sidebar label sub-content ──────────────────────── */
#ease360Layout .viewer-label .example-info {
    margin-top: 8px;
}

#ease360Layout .viewer-label .goto-buttons {
    margin-top: 10px;
    justify-content: center;
}

/* ── Example prev/next navigation ───────────────────── */
.example-nav {
    display: flex;
    justify-content: space-between;
    padding: 32px 0;
    border-top: 1px solid var(--border);
    margin-top: 48px;
}

.example-nav a {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--accent);
    text-decoration: none;
    padding: 10px 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all var(--transition);
}

.example-nav a:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: rgba(80, 197, 187, 0.08);
}

.example-nav .placeholder {
    visibility: hidden;
}

.copy {
    color: var(--text-muted);
    font-size: 1.25rem;
    line-height: 1.5;
    max-width: 720px;
}

/* ── Section headings ────────────────────────────────── */
h1,
h2,
h3 {
    font-family: var(--font-body);
    font-weight: 600;
}

h2 {
    font-size: 1.4rem;
    color: #d5d7d6;
    margin: 48px 0 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    letter-spacing: -0.01em;
}

h2::before {
    content: '// ';
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 0.9rem;
}

/* ── Download button ─────────────────────────────────── */
.download-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    background: #0a7eee;
    color: var(--bg);
    border: none;
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    overflow: hidden;
}

/* Shimmer streak */
.download-btn::after {
    content: '';
    position: absolute;
    top: -20%;
    left: -80%;
    width: 50%;
    height: 140%;
    background: linear-gradient(105deg,
            transparent 30%,
            rgba(255, 255, 255, 0.55) 50%,
            transparent 70%);
    transform: skewX(-15deg);
    transition: none;
    pointer-events: none;
}

.download-btn:hover {
    color: var(--bg);
    /* transform: translateY(-1px); */
    box-shadow: 0 8px 24px rgba(80, 197, 187, 0.25);
}

.download-btn:hover::after {
    animation: shimmer 0.85s ease forwards;
}

@keyframes shimmer {
    0% {
        left: -80%;
    }

    100% {
        left: 130%;
    }
}

.download-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* ── Tables ──────────────────────────────────────────── */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
}

thead {
    background: var(--surface2);
}

th {
    text-align: left;
    padding: 12px 16px;
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
    line-height: 1.6;
    color: var(--text-muted);
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

td:first-child {
    color: var(--text);
}

/* index.php API tables: tables with the same number of columns share column widths, so the
   3-column tables line up with each other, the 4s with each other, and the 5 stands alone.
   Desktop only: at 1024px and below each row becomes a card (see the max-width block). */
@media (min-width: 1025px) {
    table.api {
        table-layout: fixed;
    }

    table.api td code {
        overflow-wrap: anywhere;
    }

    /* Property / Method / Callback  |  Type / Parameters / Argument  |  Description */
    table.api.cols-3 th:nth-child(1) { width: 34%; }
    table.api.cols-3 th:nth-child(2) { width: 22%; }
    table.api.cols-3 th:nth-child(3) { width: 44%; }

    /* Key / Option  |  Type  |  Required / Default  |  Description */
    table.api.cols-4 th:nth-child(1) { width: 22%; }
    table.api.cols-4 th:nth-child(2) { width: 16%; }
    table.api.cols-4 th:nth-child(3) { width: 12%; }
    table.api.cols-4 th:nth-child(4) { width: 50%; }

    /* Option  |  Type  |  Required  |  Default  |  Description */
    table.api.cols-5 th:nth-child(1) { width: 16%; }
    table.api.cols-5 th:nth-child(2) { width: 14%; }
    table.api.cols-5 th:nth-child(3) { width: 10%; }
    table.api.cols-5 th:nth-child(4) { width: 14%; }
    table.api.cols-5 th:nth-child(5) { width: 46%; }
}

/* ── Code ────────────────────────────────────────────── */
code {
    font-family: var(--font-mono);
    font-size: 1em;
    color: var(--accent);
    padding: 2px 6px;
}

pre {
    background: var(--code-bg) !important;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px !important;
    overflow-x: auto;
    font-size: 1rem;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
}

pre code {
    background: none;
    border: none;
    padding: 0;
    color: inherit;
    font-size: inherit;
}

/* ── Feature list ────────────────────────────────────── */
ul.features {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
}

ul.features li {
    padding: 12px 16px 12px 40px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    position: relative;
    font-size: 1.2rem;
}

ul.features li::before {
    content: '✓';
    position: absolute;
    left: 14px;
    top: 12px;
    color: var(--accent);
    font-weight: 700;
}

/* ── Label bar ───────────────────────────────────────── */
#ease360Layout .viewer-label {
    width: 100%;
    text-align: center;
    display: block;
    background: var(--surface2);
    padding: 12px 20px;
    border-top: 1px solid var(--border);
}

#ease360Layout .viewer-label h3 {
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--text-muted);
    margin: 0;
}

/* ── What you'll learn list ───────────────────────────────── */
.learn-list {
    margin: 0 0 2rem 0;
    padding: 0 0 0 1.25rem;
    list-style-type: disc;
}

.learn-list li {
    font-size: 1.1rem;
    line-height: 1.6;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
    padding-left: 0.25rem;
}

.learn-list li::marker {
    color: var(--accent);
}

.controllers {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 100;
    pointer-events: none;
}

.controllers .left,
.controllers .right {
    width: 52px;
    height: 100px;
    position: absolute;
    background: transparent;
    top: calc(50% - 50px);
    pointer-events: all;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity var(--transition);
}

.controllers .right {
    right: 0;
}

.controllers .right svg {
    transform: rotate(180deg);
}

.controllers .left:hover,
.controllers .right:hover {
    opacity: 0.6;
}

.controllers svg {
    width: 36px;
    height: 36px;
    opacity: 1;
    color: var(--text);
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.5));
}

.controllers .left:focus-visible,
.controllers .right:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
    border-radius: 4px;
}

/* ── Footer ──────────────────────────────────────────── */
footer {
    margin-top: 80px;
    padding: 32px 0;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

footer span {
    color: var(--accent);
}

/* ── Responsive ──────────────────────────────────────── */

/* ── Wide desktop — 1920px and up ── */
@media (min-width: 1920px) {
    #myEase360 {
        height: 760px;
    }
}

/* ── Desktop — 1440px and up ── */
@media (min-width: 1440px) {
    #myEase360 {
        height: 600px;
    }
}

/* ── Laptop — up to 1024px ── */
@media (max-width: 1024px) {
    #myEase360 {
        height: 420px;
    }
}

/* ── API tables as cards + tighter page padding — up to 1024px ── */
@media (max-width: 1024px) {
    #index {
        padding: 0 12px;
    }

    /* API tables (Settings, Breakpoint object, Properties, Methods, Callbacks):
       one card per row up to 1024px. Each cell carries a data-label that stands in for its
       column header, and cells that are just "—" are hidden. */
    table.api,
    table.api tbody {
        display: block;
        width: 100%;
    }

    table.api {
        background: none;
        border: 0;
        border-radius: 0;
        overflow: visible;
    }

    table.api thead {
        display: none;
    }

    table.api tr {
        display: flex;
        flex-direction: column;
        gap: 8px;
        padding: 14px 16px;
        margin-bottom: 12px;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius);
    }

    table.api tr:last-child {
        margin-bottom: 0;
    }

    /* cells stay block-level so inline <code> and links flow as normal text;
       the label sits in the left gutter via absolute positioning */
    table.api td,
    table.api tr:hover td {
        position: relative;
        display: block;
        padding: 0 0 0 6rem;
        border: 0;
        background: none;
        color: var(--text);
        min-width: 0;
        overflow-wrap: anywhere;
    }

    table.api td::before {
        content: attr(data-label);
        position: absolute;
        left: 0;
        top: 0;
        width: 5.5rem;
        font-size: 0.8rem;
        font-weight: 600;
        line-height: 1.9;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: var(--text-muted);
    }

    table.api td code {
        padding: 0 2px;
    }

    /* the option / method name leads the card */
    table.api td.c-main {
        padding: 0 0 8px;
        border-bottom: 1px solid var(--border);
        font-size: 1.05rem;
        font-weight: 600;
    }

    /* long text reads better with its label above it */
    table.api td[data-label="Description"],
    table.api td[data-label="Parameters"],
    table.api td[data-label="Argument"] {
        padding-left: 0;
    }

    table.api td[data-label="Description"]::before,
    table.api td[data-label="Parameters"]::before,
    table.api td[data-label="Argument"]::before {
        position: static;
        display: block;
        width: auto;
        margin-bottom: 2px;
    }

    table.api td.na {
        display: none;
    }
}

/* ── Example layout column mode — controls must be fully constrained ── */
@media (max-width: 1023px) {
    #controls {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow: hidden;
        box-sizing: border-box;
    }

    pre {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
}

/* ── Mobile nav (details/summary — pure CSS) ─────────── */
.mobile-nav {
    display: none;
    position: relative;
}

.mobile-nav-toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 36px;
    height: 36px;
    cursor: pointer;
    list-style: none;
    padding: 4px;
    border-radius: 6px;
    transition: background var(--transition);
}

/* Remove default details marker in all browsers */
.mobile-nav-toggle::-webkit-details-marker {
    display: none;
}

.mobile-nav-toggle::marker {
    display: none;
}

.mobile-nav-toggle:hover {
    background: rgba(80, 197, 187, 0.1);
}

.mobile-nav-toggle span {
    display: block;
    height: 2px;
    width: 100%;
    background: var(--text-muted);
    border-radius: 2px;
    transition: background var(--transition), transform 0.2s, opacity 0.2s;
    transform-origin: center;
}

.mobile-nav-toggle:hover span {
    background: var(--accent);
}

/* Animate to X when open */
.mobile-nav[open] .mobile-nav-toggle span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.mobile-nav[open] .mobile-nav-toggle span:nth-child(2) {
    opacity: 0;
}

.mobile-nav[open] .mobile-nav-toggle span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

.mobile-nav-menu {
    position: fixed;
    top: 61px;
    left: 0;
    right: 0;
    background: var(--tinthighlight);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
    padding: 8px 0 16px;
    z-index: 900;
    display: flex;
    flex-direction: column;
}

.mobile-nav-menu a {
    display: block;
    padding: 12px 24px;
    color: var(--text-menu);
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    transition: color var(--transition), background var(--transition);
}

.mobile-nav-menu a:hover {
    color: var(--text);
    background: rgba(80, 197, 187, 0.07);
}

.mobile-nav-label {
    padding: 12px 24px 6px;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent);
}

@media (max-width: 768px) {
    .mobile-nav {
        display: block;
    }
}

/* ── Tablet — up to 768px ── */
@media (max-width: 768px) {
    #myEase360 {
        height: 340px;
    }

    .nav-links {
        display: none;
    }

    .viewer-controls {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
}

/* ── Mobile — up to 640px ── */
@media (max-width: 640px) {
    #index {
        padding: 0 12px;
        overflow-x: hidden;
    }

    #ease360Layout {
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    #myEase360 {
        height: 200px;
    }

    /* home hero: the mobile frame sets are 4:3, so the viewer is a locked 4:3 box.
       The canvas is taken out of the box's sizing (absolute) so a stale canvas size
       from an earlier breakpoint or resize can never prop the box open. */
    #ease360Layout.hero-crop:not(.is-fs):not(:fullscreen) #myEase360 {
        position: relative;
        height: auto;
        min-height: 0;
        aspect-ratio: 4 / 3;
        overflow: hidden;
    }

    #ease360Layout.hero-crop:not(.is-fs):not(:fullscreen) #myEase360 canvas {
        position: absolute;
        top: 0;
        left: 0;
    }

    /* no chevron buttons on phones: drag (or the degree buttons) turns the viewer */
    .chev-btn {
        display: none;
    }

    /* full screen on a portrait phone keeps 4:3: the largest 4:3 box that fits */
    #ease360Layout.hero-crop.is-fs #myEase360,
    #ease360Layout.hero-crop:fullscreen #myEase360 {
        width: min(100vw, 133.333vh);
        height: min(75vw, 100vh);
    }

    @supports (height: 100dvh) {
        #ease360Layout.hero-crop.is-fs #myEase360,
        #ease360Layout.hero-crop:fullscreen #myEase360 {
            width: min(100vw, 133.333dvh);
            height: min(75vw, 100dvh);
        }
    }

    .viewer-controls {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    #controls {
        padding: 0;
    }
}

/* ── Mobile small — up to 375px ── */
@media (max-width: 375px) {
    #myEase360 {
        height: 160px;
    }

    .viewer-controls {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
}