/* ==========================================================
   TOY BOX PAGE — toybox.css
   Page-specific styles for fonts/toybox.html
   ========================================================== */

/* CSS Variables */
:root {
    --kilt-green:     #01924f;
    --kilt-blue:      #3676b8;
    --kilt-red:       #d43b2a;
    --tb-yellow:      #ffaf38;
    --tb-black:       #000000;
    --tb-bg:          #ebbdb0;
    --grid-yellow:    rgba(255, 175, 56, 0.25);
    --section-gap:    3rem;
}

/* ==========================================================
   PAGE WRAPPER
   ========================================================== */

#tb-page {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    gap: var(--section-gap);
    width: 100%;
}

/* ==========================================================
   SECTION 1 — HERO
   ========================================================== */

#tb-hero {
    width: 100%;
    padding: 1.5rem;
}

.tb-hero-title {
    width: 100%;
    height: auto;
    display: block;
}

/* ==========================================================
   SECTION 2 — ABOUT
   ========================================================== */

#tb-about {
    width: 100%;
    padding: 1.5rem;
    position: relative;   /* anchor the duck */
}

.tb-about-text {
    font-family: monospace;
    font-size: 10px;
    line-height: 30px;   /* explicit px — must match gradient period exactly */
    max-width: 600px;
    margin: 0 auto;
    background: repeating-linear-gradient(
        transparent 0,
        transparent 18px,
        var(--grid-yellow) 0px,
        var(--grid-yellow) 30px
    );
    padding: 0 1rem 1rem;
}

.tb-about-text p {
    margin-top: 0;
    margin-bottom: 0;
}

.tb-about-text p + p {
    margin-top: 30px;
}

/* Duck sits at bottom of about section, overlapping the Matter.js box top edge */
.tb-duck {
    position: absolute;
    bottom: -52px;
    left: 6%;
    width: 60px;
    height: auto;
    z-index: 10;
}

/* ==========================================================
   SECTION 3 — MATTER.JS PHYSICS BOX
   ========================================================== */

#tb-matter {
    width: 100%;
    height: 500px;
    border: 3px solid var(--tb-black);
    overflow: hidden;
    position: relative;
    box-sizing: border-box;
}

#tb-matter canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

/* Hint label — top-left corner of the physics box */
.tb-matter-hint {
    position: absolute;
    top: 10px;
    left: 12px;
    margin: 0;
    font-family: monospace;
    font-size: 10px;
    color: var(--tb-black);
    opacity: 0.45;
    pointer-events: none;
    z-index: 5;
    user-select: none;
}

/* Hidden SVG container — paths are read by Matter.js, not displayed */
#tb-svgs {
    display: none;
}

/* ==========================================================
   SECTION 4 — TYPE TESTER (DASHED SLIDERS + NOTEPAD)
   ========================================================== */

#tb-tester {
    width: 100%;
}

/* --- Control Panel --- */

.tb-control-panel {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1.5rem;
    padding-top: 1rem;
    padding-bottom: 1rem;
    margin-bottom: 0.5rem;
}

.tb-slider-row {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.tb-slider-row h2 {
    font-family: monospace;
    font-size: 0.75rem;
    font-weight: normal;
    white-space: nowrap;
    letter-spacing: 0.08em;
}

/* Dashed slider track */
.tb-slider-row input[type='range'] {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    border: none;
    border-radius: 0;
    flex: 1;
    cursor: pointer;
    height: 20px;
}

.tb-slider-row input[type='range']::-webkit-slider-runnable-track {
    height: 2px;
    background: repeating-linear-gradient(
        90deg,
        var(--tb-black) 0,
        var(--tb-black) 5px,
        transparent 5px,
        transparent 10px
    );
}

.tb-slider-row input[type='range']::-moz-range-track {
    height: 2px;
    background: repeating-linear-gradient(
        90deg,
        var(--tb-black) 0,
        var(--tb-black) 5px,
        transparent 5px,
        transparent 10px
    );
    border: none;
}

.tb-slider-row input[type='range']::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--tb-black);
    margin-top: -6px;
    cursor: pointer;
}

.tb-slider-row input[type='range']::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--tb-black);
    border: none;
    cursor: pointer;
}

/* --- Notepad --- */

.tb-notepad-wrapper {
    position: relative;
    margin-top: 0.25rem;
    isolation: isolate;
}

/* Shadow page */
.tb-notepad-wrapper::before {
    content: '';
    position: absolute;
    inset: 0;
    border: 3px solid var(--tb-black);
    background: rgba(255, 175, 56, 0.12);
    transform: translate(12px, 12px);
    z-index: 0;
}

.tb-notepad {
    position: relative;
    z-index: 2;
    border: 3px solid var(--tb-black);
    background:
        var(--tb-bg)
        repeating-linear-gradient(
            transparent 0,
            transparent 27px,
            var(--grid-yellow) 27px,
            var(--grid-yellow) 30px
        );
    padding: 0 1.5rem 2rem 4rem;
    min-height: 250px;
}

/* Perforation line */
.tb-notepad-perf {
    height: 24px;
    background: repeating-linear-gradient(
        90deg,
        var(--tb-black) 0,
        var(--tb-black) 8px,
        transparent 8px,
        transparent 63px
    );
    background-position: center;
    margin-bottom: 1rem;
    transform: translate(-1px, -15px);
    margin-left: 0.5rem;
    margin-right: 0.5rem;
}

/* Yellow margin line */
.tb-notepad::before {
    content: '';
    position: absolute;
    left: 3rem;
    top: 0;
    bottom: 0;
    border-left: 3px solid color-mix(in srgb, var(--kilt-blue) 18%, transparent);
    z-index: 3;
}

/* Typing area */
#tb-area {
    font-family: 'toy-box', sans-serif;
    font-variation-settings: 'HOLE' 0;
}

#tb-text     { display: block; }
#tb-text-mob { display: none; }

#tb-tester .typing-area {
    text-align: left;
    overflow: visible;
    outline: none;
    color: var(--tb-black);
    font-size: 120px;
    line-height: 150px;
}

/* ==========================================================
   SECTION 5 — GLYPH SPECIMEN
   ========================================================== */

#tb-specimen {
    padding: 1.5rem 0;
}

.tb-specimen-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2.5rem;
    align-items: center;
}

.tb-specimen-text {
    font-family: monospace;
    font-size: 10px;
    line-height: 30px;
    background: repeating-linear-gradient(
        transparent 0,
        transparent 18px,
        var(--grid-yellow) 0px,
        var(--grid-yellow) 30px
    );
    padding: 0 1rem 1rem;
}

.tb-specimen-text p {
    margin: 0 0 1rem;
    padding-bottom: 0.4rem;
    min-height: 1.6em;
}

.tb-specimen-box {
    background: var(--tb-bg);
    padding: 1.5rem;
}

.tb-specimen-img {
    width: 100%;
    height: auto;
    display: block;
}

/* ==========================================================
   SECTION 6 — LETTER CONSTRUCTION
   ========================================================== */

#tb-construction {
    padding: 0.4rem;
}

.tb-construction-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: center;
}

.tb-construction-box {
    margin: 0;
}

.tb-construction-img {
    width: 100%;
    height: auto;
    display: block;
}

.tb-construction-text {
    font-family: monospace;
    font-size: 10px;
    line-height: 30px;
    background: repeating-linear-gradient(
        transparent 0,
        transparent 18px,
        var(--grid-yellow) 0px,
        var(--grid-yellow) 30px
    );
    padding: 0 1rem 1rem;
}

.tb-construction-text p {
    margin: 0 0 1rem;
    padding-bottom: 0.4rem;
    min-height: 1.6em;
}

/* ==========================================================
   SECTION 7 — INTERACTIVE ALPHABET GRID
   ========================================================== */

#tb-alphabet {
    width: 100%;
    padding: 1.5rem 0;
}

.tb-alphabet-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2.5rem;
    align-items: stretch;
}

.tb-glyph-viewer {
    display: block;
}

.tb-glyph-img {
    width: 100%;
    height: auto;
    display: block;
}

/* A–Z list — Toy Box font, HOLE=60, stroke-only default */
.tb-az-list {
    list-style: none;
    padding: 18px;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    align-content: space-between;
    font-family: 'toy-box', sans-serif;
    font-variation-settings: 'HOLE' 60;
    font-size: 2.5rem;
    cursor: default;
    user-select: none;
}

.tb-az-list li {
    display: flex;
    align-items: center;
    justify-content: center;
    color: transparent;
    -webkit-text-stroke: 1.5px var(--tb-black);
    transition: color 0.12s ease;
    cursor: pointer;
}

.tb-az-list li:hover,
.tb-az-list li.active {
    color: var(--tb-black);
}

/* ==========================================================
   MOBILE STYLES — max-width: 576px
   ========================================================== */

@media (max-width: 576px) {

    #tb-about { margin-top: -4rem; }

    .tb-about-text {
        font-size: 10px;
        line-height: 30px;
        max-width: 100%;
    }

    .tb-duck {
        width: 44px;
    }

    #tb-matter {
        height: 320px;
    }

    .tb-control-panel           { grid-template-columns: 1fr; }
    .tb-slider-row:nth-child(2) { display: none; }   /* hide LEADING on mobile */

    #tb-tester .typing-area {
        line-height: 1.2;
    }

    #tb-text     { display: none; }
    #tb-text-mob { display: block; }

    /* --- SECTION 5: Single column specimen --- */
    .tb-specimen-layout { grid-template-columns: 1fr; }

    /* --- SECTION 6: Hide construction on mobile --- */
    #tb-construction { display: none; }

    /* --- SECTION 7: Stack layout, A–Z on top, viewer below --- */
    .tb-alphabet-layout { grid-template-columns: 1fr; }
    .tb-glyph-viewer    { order: 2; }
    .tb-az-list {
        order: 1;
        grid-template-columns: repeat(9, 1fr);   /* 3 rows: 9 + 9 + 8 */
        font-size: 1.8rem;
        padding: 8px;
    }

}
