﻿/* codes.css — Mobile-first; Blue / Silver / Black system */
/* VS-friendly: no `text-wrap` */

:root {
    --blue-500: #1a73e8;
    --blue-600: #155cc7;
    --blue-800: #0f3a7a;
    --bg-900: #0b0d10;
    --bg-800: #101418;
    --bg-700: #141a20;
    --silver-50: #f3f6fa;
    --silver-100: #e7edf5;
    --silver-300: #c9d3e2;
    --silver-500: #98a6bd;
    --border: rgba(255,255,255,0.08);
    --focus: #8ab4ff;
    --radius-8: 8px;
    --radius-12: 12px;
    --radius-16: 16px;
    --tap: 44px;
    --shadow-1: 0 2px 10px rgba(0,0,0,.35);
    --shadow-2: 0 8px 22px rgba(0,0,0,.45);
    --color-button-bg: var(--blue-600);
    --appbar-h: 56px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    min-height: 100%;
    background: var(--bg-900);
    color: var(--silver-100);
    font-family: system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial,sans-serif;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* Long text safety without text-wrap */
h1, h2, h3, p, a, label {
    overflow-wrap: break-word;
    word-wrap: break-word
}

/* ===== App Bar (brand + actions) ===== */
.appbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    height: var(--appbar-h);
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    padding: 0 12px;
    background: linear-gradient(180deg, rgba(16,20,24,0.95) 0%, rgba(16,20,24,0.9) 100%);
    border-bottom: 1px solid var(--border);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.brand__logo {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: #fff;
    font-size: 16px;
    background: radial-gradient(120% 120% at 30% 30%, var(--blue-500), var(--blue-800));
    box-shadow: var(--shadow-1);
}

.brand__text {
    font-weight: 700;
    font-size: 16px;
    letter-spacing: .2px;
}

.brand__beta {
    font-size: 11px;
    color: var(--silver-300);
    padding: 2px 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius-12);
}

.appbar__actions {
    display: flex;
    gap: 8px;
}

/* Buttons (shared) */
.btn {
    appearance: none;
    border: 1px solid rgba(138,180,255,.35);
    border-radius: var(--radius-12);
    min-height: calc(var(--tap) + 4px);
    padding: 12px 16px;
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
    color: #fff;
    background: linear-gradient(180deg, rgba(26,115,232,.18), rgba(26,115,232,.12)), var(--blue-600);
    box-shadow: 0 8px 18px rgba(26,115,232,.18);
    transition: transform 120ms ease, filter 120ms ease, box-shadow 120ms ease;
}

    .btn:hover {
        filter: brightness(1.05);
        transform: translateY(-1px);
        box-shadow: 0 10px 22px rgba(26,115,232,.22);
    }

    .btn:active {
        transform: translateY(0);
    }

    .btn:disabled {
        opacity: .65;
        cursor: not-allowed;
    }

.btn--ghost {
    color: var(--silver-100);
    background: rgba(255,255,255,.08);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-1);
}

/* ===== Page layout ===== */
.page {
    display: flex;
    flex-direction: column;
    min-height: calc(100dvh - var(--appbar-h));
    max-width: 820px;
    margin: 0 auto;
    padding: clamp(12px, 4vw, 20px);
    gap: 10px;
}

/* Title */
#codes-container > h1 {
    margin: 2px 2px 6px;
    font-size: clamp(20px, 5vw, 24px);
    font-weight: 800;
    color: var(--silver-50);
}

/* Search */
.controls {
    display: grid;
    gap: 6px;
}

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

#search {
    width: 100%;
    min-height: var(--tap);
    border: 1px solid var(--border);
    border-radius: var(--radius-12);
    background: var(--bg-700);
    color: var(--silver-100);
    padding: 12px;
    font-size: 16px; /* prevent iOS zoom */
    outline: none;
    transition: border-color 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
}

    #search::placeholder {
        color: var(--silver-500);
    }

    #search:focus {
        border-color: rgba(138,180,255,0.35);
        box-shadow: 0 0 0 2px rgba(138,180,255,0.25);
    }

/* Scrollable results area */
.codes-scroll {
    flex: 1 1 auto;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-16);
    background: var(--bg-800);
    box-shadow: var(--shadow-2);
    padding: 10px;
    min-height: 180px;
}

/* Codes list (what codes.js fills) */
#codes-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 10px;
}

    #codes-list > li,
    #codes-list > div,
    #codes-list > article {
        background: var(--bg-700);
        border: 1px solid var(--border);
        border-radius: var(--radius-12);
        box-shadow: var(--shadow-1);
        padding: 12px;
    }

    #codes-list strong {
        color: var(--silver-50);
        font-weight: 800;
    }

    #codes-list p {
        margin: 4px 0 0;
        color: var(--silver-300);
        line-height: 1.55;
    }

    #codes-list mark {
        background: rgba(26,115,232,.25);
        color: var(--silver-50);
        padding: 0 .15em;
        border-radius: 4px;
    }

/* Back to Directory stays at the bottom of page layout */
#back-to-directory-container {
    text-align: center;
}

#back-to-directory-button {
    box-shadow: var(--shadow-1);
    border: 1px solid rgba(138,180,255,0.30);
}

    #back-to-directory-button:hover {
        transform: translateY(-1px);
        filter: brightness(1.05);
    }

    #back-to-directory-button:active {
        transform: translateY(0);
    }

/* Light Mode */
@media (prefers-color-scheme: light) {
    :root {
        --bg-900: #ffffff;
        --bg-800: #f7f9fc;
        --bg-700: #ffffff;
        --border: rgba(0,0,0,0.08);
        --silver-50: #0b1220;
        --silver-100: #1b2436;
        --silver-300: #3b4b69;
        --silver-500: #6b7a96;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .btn, #search, #back-to-directory-button {
        transition: none !important;
    }
}
