/* ── Design Tokens ─────────────────────────────────── */
:root {
    --bg: #0d1117;
    --surface: #161b24;
    --surface2: #1e2535;
    --border: #2a3347;
    --accent: #50c5bb;
    --accent2: #f0b429;
    --text: #e2e8f0;
    --text-muted: #8892a4;
    --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: #9d26ac;
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: #b83fc9;
}

*,
*::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 ─────────────────────────────────────────────────────────────
 *  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;
}

/* ── 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: var(--text);
    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: var(--accent);
    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);
}

/* ── 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;
    transition: border-color var(--transition);
}

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

ul.features li:hover {
    border-color: var(--accent);
}

/* ── 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;
    }
}

/* ── 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 16px;
        overflow-x: hidden;
    }

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

    #myEase360 {
        height: 200px;
    }

    .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;
    }
}