/* ==============================================
   Schriftlabor Specimen Page
   ============================================== */

:root {
  
    --spec-ui-line:    rgba(0, 0, 0, 0.14);

    --spec-border:     black;
    --spec-tooltip-bg: rgba(255, 255, 255, 0.66);
    --spec-tooltip-fg: black;
}

/* Header: backdrop blur disabled on specimen so Safari reads the
   font's theme color from the header background (set via JS). */
.header {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}


@media (prefers-color-scheme: dark) {
    .spec-bar {
    background-color: rgba(0, 0, 0, 0.7);
    }

    .spec-select,
    .spec-label,
    .spec-val,
    .spec-burger {
        color: white;
    }

    .spec-select {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='rgba(255,255,255,0.5)'/%3E%3C/svg%3E");
    }

    .wf-font-select,
    .wf-style-select,
    .wf-size-select,
    .wf-link-btn,
    .wf-reset-btn,
    .wf-label {
        color: white;
    }

    .spec-shops {
        color: white;
    }

    .spec-shops a {
        color: white;
    }
}


/* ── Controls bar ── */

.spec-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    padding: 0 4vw;

    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    position: sticky;
    top: 0;            /* updated by JS to sit below header */
    z-index: 9;
    min-height: 48px;
}

.spec-selects {
    display: flex;
    align-items: flex-end;
    flex-shrink: 0;
}

#style-select {
    min-width: 13rem;
}

#font-select {
    min-width: 12rem;
}

.spec-select {
    -webkit-appearance: none;
    appearance: none;
    background: transparent
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='rgba(0,0,0,0.35)'/%3E%3C/svg%3E")
        no-repeat right 0.4rem center;
    border: none;
    padding: 0.5rem 1.7rem 0.5rem 0.5rem;
    line-height: 1.6;
    font-size: 0.9rem;
    letter-spacing: 0.04em;
    color: var(--spec-ui-text);
    cursor: pointer;
    outline: none;
    white-space: nowrap;
    font-family: strokeWeight, sans-serif;
    font-variation-settings: "wght" 100, "slnt" 0;
    transition: color 0.15s;
}

.spec-select:hover { color: var(--spec-border); }



/* ── Slider pool (axis + size sliders) ── */

.spec-pool {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    flex: 1;
    min-width: 0;
    padding: 2px 0;
}

/* axis-controls uses display:contents so its .spec-ctrl children
   participate directly in spec-pool's flex layout */
#axis-controls {
    display: contents;
}

/* Hide size slider from spec-bar - keep it only in paragraph section */
.spec-pool .spec-ctrl:has(#size-slider) {
    display: none;
}


.spec-ctrl {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.45rem 1rem;
}

.spec-label {
    font-size: 0.68rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--spec-ui-text);
    user-select: none;
    white-space: nowrap;
    font-family: strokeWeight, sans-serif;
    font-variation-settings: "wght" 100, "slnt" 0;
}

.spec-val {
    font-size: 0.68rem;
    color: var(--spec-ui-text);
    font-variant-numeric: tabular-nums;
    min-width: 2.4rem;
    text-align: right;
    white-space: nowrap;
    font-family: strokeWeight, sans-serif;
    font-variation-settings: "wght" 100, "slnt" 0;
}

.spec-range {
    -webkit-appearance: none;
    appearance: none;
    width: 80px;
    height: 1px;
    background: var(--spec-ui-line);
    border: none;
    outline: none;
    cursor: pointer;
    flex-shrink: 0;
}

.spec-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--spec-border);
    opacity: 0.45;
    cursor: pointer;
    transition: opacity 0.15s;
}

.spec-range:hover::-webkit-slider-thumb,
.spec-range:focus::-webkit-slider-thumb {
    opacity: 1;
}

.spec-range::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--spec-border);
    opacity: 0.45;
    border: none;
    cursor: pointer;
}

@media (min-width: 900px) {
    .spec-range { width: 100px; }
}

@media (max-width: 480px) {
    .spec-range { width: 56px; }
    .spec-ctrl  { padding: 0.3rem 0.45rem; gap: 0.3rem; justify-content: center; }
}


/* ── OpenType feature buttons ── */

.spec-feature-btn {
    background: transparent;
    border: 1px solid var(--spec-ui-line);
    border-radius: 3px;
    padding: 0.15rem 0.4rem;
    font-size: 0.65rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--spec-ui-text);
    font-family: strokeWeight, sans-serif;
    font-variation-settings: "wght" 100, "slnt" 0;
    cursor: pointer;
    line-height: 1.5;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.spec-feature-btn:hover {
    color: var(--spec-border);
    border-color: var(--spec-border);
}

.spec-feature-btn.active {
    background: var(--spec-border);
    border-color: var(--spec-border);
    color: var(--spec-bar-bg, #fff);
}

@media (prefers-color-scheme: dark) {
    .spec-feature-btn.active {
        color: white;
    }
}


/* ── Main specimen stage ── */

.spec-stage {
    min-height: 25vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5vw 4vw 7vw;
    transition: background-color 0.35s ease;
}

.spec-text {
    font-size: 120px;
    line-height: 1;
    text-align: center;
    color: black;
    outline: none;
    cursor: text;
    word-break: break-word;
    width: 100%;
    background: transparent;
    caret-color: black;
    padding-bottom: 0.2em;
}

.spec-text:empty::before {
    content: attr(data-placeholder);
    opacity: 0.25;
    pointer-events: none;
}

@media (prefers-color-scheme: dark) {
    .spec-text {
        color: white;
        caret-color: white;
    }
}


/* ── Buy links ── */

.spec-shops {
    position: sticky;
    top: 0; /* updated by JS to sit below spec-bar */
    z-index: 8;
    padding: 0.6em 4vw;
    font-size: 1rem;
    color: var(--spec-border);
    font-family: strokeWeight, sans-serif;
    font-variation-settings: "wght" 300, "slnt" 0;
    letter-spacing: 0.04em;
    text-align: center;
    transition: background-color 0.35s ease, color 0.35s ease;
    background-color: white;
}

.spec-shops a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 0.2em;
}

.spec-shops a:hover {
    color: var(--spec-border);
}


/* ── Waterfall ── */

.spec-waterfall {
    padding: 1em 0;
}

.wf-row {
    display: flex;
    flex-direction: column;
    padding: 0.12em 4vw;
    position: relative;
    overflow-x: hidden;
}


.wf-hover-controls {
    display: flex;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.6s 0.5s;
    padding: 0 4px;
}

.wf-row:hover .wf-hover-controls {
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.15s;
}

.wf-font-select,
.wf-style-select,
.wf-size-select {
    padding-top: 0.3rem;
    padding-bottom: 0.3rem;
    padding-right: 1.2rem;
}

.wf-size-select {
    width: 4.5rem;
}

.wf-link-btn {
    background: transparent;
    border: none;
    padding: 0 0.4rem 0 0.2rem;
    color: var(--spec-ui-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    transition: color 0.15s;
}

.wf-link-btn svg { transform: rotate(90deg); }
.wf-link-btn:hover { color: var(--spec-border); }
.wf-link-btn.unlinked { opacity: 0.4; }

.wf-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 6px 4vw;
}

.wf-reset-btn {
    background: transparent;
    border: none;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: var(--spec-ui-text);
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: transform 0.35s ease, color 0.15s;
    margin-left: auto;
}

.wf-reset-btn:hover {
    color: var(--spec-border);
    transform: rotate(180deg);
}

.wf-label {
    font-size: 0.65rem;
    letter-spacing: 0.05em;
    color: var(--spec-ui-text);
    min-width: 2.8rem;
    flex-shrink: 0;
    user-select: none;
    padding: 0.6em 0;
    font-family: strokeWeight, sans-serif;
    font-variation-settings: "wght" 100, "slnt" 0;
}

.wf-text {
    line-height: 1.1;
    white-space: nowrap;
    overflow: visible;
    text-overflow: clip;
    padding: 0.08em 0 0.25em 0;
    text-align: left;
    outline: none;
    cursor: text;
}


/* ── Paragraph columns ── */

.spec-columns {
    padding: 0;
}

.spec-col-controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0;
    padding: 6px 4vw;
}

.spec-col-sliders {
    display: flex;
    align-items: center;
    margin-left: auto;
    margin-right: 0;
}


.spec-col-btn {
    background: transparent;
    border: none;
    padding: 0.25rem 0.7rem;
    font-size: 0.68rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--spec-ui-text);
    cursor: pointer;
    font-family: strokeWeight, sans-serif;
    font-variation-settings: "wght" 100, "slnt" 0;
    transition: color 0.15s, background 0.15s;
    margin-right: -1px;
}

.spec-col-refresh,
.spec-col-reset-typo {
    background: transparent;
    border: none;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: var(--spec-ui-text);
    cursor: pointer;
    margin-left: 0.5rem;
    padding: 0;
    line-height: 1;
    transition: transform 0.35s ease, color 0.15s;
}

.spec-col-refresh {
    font-size: 1.3rem;
    height: 24px;
    overflow: visible;
    position: relative;
    top: -2px;
}

.spec-col-refresh:hover {
    color: var(--spec-border);
}

.spec-col-reset-typo:hover {
    color: var(--spec-border);
    transform: rotate(180deg);
}

.spec-col-btn.active {
    background: transparent;
    color: var(--spec-border);
}

.spec-col-text {
    column-count: 2;
    column-gap: 2.5em;
    column-rule: none;
    padding: 2.5em 4vw 3em;
    font-size: 11pt;
    line-height: 1.6;
    outline: none;
    cursor: text;
}

.spec-col-text p {
    margin: 0 0 1em;
    width: 100%;
}

.spec-col-text p:last-child { margin-bottom: 0; }

@media (max-width: 599px) {
    .spec-col-text { column-count: 1 !important; }
}

@media (min-width: 760px) {
    .spec-col-text { font-size: 12pt; }
}


/* ── Styles showcase ── */

.spec-styles {
    padding: 1.5em 4vw;
}

.style-row {
    padding: 0 0 0.3em;
    line-height: 1.2;
    white-space: pre-wrap;
    tab-size: 4;
    text-align: left;
}

.style-row-text {
    display: inline;
    padding: 0;
    margin: 0 1em 0 0;
    background: none;
    border: none;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    color: inherit;
    font-size: inherit;
    line-height: inherit;
    text-align: inherit;
}
.style-row-text:hover {
    opacity: 0.6;
}


/* ── Glyph grid ── */

.spec-glyphs {
    padding: 4vw 4vw 8vw;
}

.spec-glyphs-empty {
    padding: 3rem 4vw;
    font-size: 0.78rem;
    color: var(--spec-ui-text);
    font-family: strokeWeight, sans-serif;
    font-variation-settings: "wght" 100, "slnt" 0;
    letter-spacing: 0.04em;
}

.glyph-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(32px, 1fr));
    gap: 1px;
}

.glyph-item {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: default;
    border-radius: 3px;
    transition: background 0.1s ease, transform 0.1s ease;
}

.glyph-item:hover {
    background: rgba(0, 0, 0, 0.07);
    transform: scale(1.1);
}

@media (prefers-color-scheme: dark) {
    .glyph-item:hover { background: rgba(255, 255, 255, 0.1); }
}

.glyph-char {
    font-size: 1.4rem;
    line-height: 1;
    pointer-events: none;
    user-select: none;
}


/* ── Glyph tooltip ── */

.glyph-tooltip {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 200;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.12s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: max(200px, 45vw);
    height: max(200px, 45vw);
    max-height: calc(100dvh - var(--top-ui-height, 90px));
    background: var(--spec-tooltip-bg);
    border-radius: 4px;
}

.glyph-tooltip.visible {
    opacity: 1;
}

.glyph-tooltip-char {
    font-size: clamp(8rem, 28vw, 28rem);
    line-height: 1;
    color: var(--spec-tooltip-fg);
    padding: 2em;
}


/* ── Burger button (tablet only) ── */

.spec-burger {
    display: none;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    width: 34px;
    height: 34px;
    background: transparent;
    border: none;
    font-size: 1rem;
    font-family: serif;
    font-weight: bold;
    color: var(--spec-ui-text);
    cursor: pointer;
    flex-shrink: 0;
    transition: color 0.15s;
}

.spec-burger:hover { color: var(--spec-border); }




/* ── Mobile passage (mobile only) ── */

.mobile-passage {
    display: none;
    position: relative;
    padding: 1.2rem 6vw;
    background: rgba(0, 0, 0, 0.04);
    align-items: center;
    justify-content: center;
}


.mobile-passage-text {
    font-size: clamp(1rem, 3.5vw, 1.4rem);
    line-height: 1.55;
    color: black;
    max-width: 72ch;
}


.mobile-passage-btn {
    position: absolute;
    top: 0.6rem;
    right: 0.8rem;
    background: transparent;
    border: none;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: var(--spec-ui-text);
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.15s;
}

.mobile-passage-btn:hover {
    color: var(--spec-border);
}



/* ── Responsive: tablet / larger touch (< 900px) ── */

@media (max-width: 899px) {
    .spec-wrap {
        display: flex;
        flex-direction: column;
        position: relative;
    }

    .spec-bar {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        padding: 0 4vw;
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        position: sticky;
        top: 0;
        z-index: 9;
        min-height: 48px;
    }

    .spec-selects {
        display: flex;
        align-items: flex-end;
        width: 100%;
        transition: background-color 0.35s ease;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    #font-select {
        flex: 1;
        min-width: 0;
    }

    #style-select {
        flex: 1;
        min-width: 0;
    }

    /* When style select needs to wrap, put it on its own row */
    .spec-selects.style-wrap {
        flex-direction: column;
        align-items: stretch;
    }

    .spec-selects.style-wrap #font-select {
        flex-basis: 100%;
    }

    .spec-selects.style-wrap #style-select {
        flex-basis: 100%;
        width: 100%;
    }

    .spec-stage {
        min-height: 25svh;
        height: auto;
        position: relative;
    }

    .spec-shops {
        position: static;
        text-align: center;
        transition: color 0.35s ease;
    }

    .mobile-passage  { 
        display: flex; 
    }

    .spec-waterfall  { display: none; }
    .spec-columns    { 
        display: none; 
        transition: background-color 0.35s ease;
    }
    .spec-styles     { display: none; }

    /* Slider bar - scrolls with content below stage */
    .spec-pool {
        display: flex !important;
        position: relative;
        width: 100% !important;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        flex-wrap: wrap;
        padding: 0.75rem 4vw !important;
        gap: 0.5rem;
        background-color: var(--spec-page-bg);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        z-index: 8;
        margin: 0;
        border: none;
        min-height: auto;
        transition: background-color 0.35s ease;
    }

    /* Hide the size slider */
    .spec-pool .spec-ctrl:has(#size-slider) {
        display: none;
    }

    /* Hide slider bar if no axis controls available */
    .spec-pool:has(> #axis-controls:not(:has(*))) {
        display: none !important;
    }

    .spec-burger { display: none; }

    .spec-glyphs {
        margin-top: auto;
    }
}
