/* site-frame.css - the frame every DreyX page shares: header, page column,
   and side column. The app (index.html, tools.html) and the server-rendered
   pages (functions/lib/sitePage.js) load this file and use the same markup
   and classes. Change the frame here only, so the pages cannot drift apart.
   Bump ?v= in index.html, tools.html and sitePage.js after a change. */

/* ── Frame tokens ──────────────────────────────────────────────────── */
:root {
    --dx-frame: 1120px;
    --dx-gutter: 16px;
    --dx-card: #ffffff;
    --dx-line: #dde2e8;
    --dx-ink: #14181d;
    --dx-link: #0b5fa5;
    --dx-meta: #626c78;
    --dx-focus: #b45309;
}

html.dark {
    --dx-card: #151a21;
    --dx-line: #242b34;
    --dx-ink: #e6eaef;
    --dx-link: #7dd3fc;
    --dx-meta: #8d98a4;
    --dx-focus: #fbbf24;
}

@media (max-width: 760px) {
    :root {
        --dx-gutter: 12px;
    }
}

/* ── Page column: the header content and the page content share it ── */
.dx-frame {
    box-sizing: border-box;
    width: 100%;
    max-width: calc(var(--dx-frame) + 2 * var(--dx-gutter));
    margin-left: auto;
    margin-right: auto;
    padding-left: var(--dx-gutter);
    padding-right: var(--dx-gutter);
}

/* ── Two columns on wide screens: content and side column ──────────── */
.dx-columns-main {
    min-width: 0;
}

.dx-side {
    display: none;
}

@media (min-width: 1000px) {
    .dx-columns {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 300px;
        column-gap: 28px;
        align-items: start;
    }

    .dx-side {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }
}

/* The side column stays in place only when the window shows all of it. */
@media (min-width: 1000px) and (min-height: 1150px) {
    .dx-side {
        position: sticky;
        top: 54px;
    }
}

.dx-aside-box {
    box-sizing: border-box;
    padding: 14px 16px;
    color: var(--dx-ink);
    background: var(--dx-card);
    border: 1px solid var(--dx-line);
    font-size: 14px;
    line-height: 1.45;
}

.dx-aside-box h2 {
    margin: 0 0 8px;
    color: var(--dx-ink);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: normal;
    text-transform: none;
}

.dx-aside-links {
    margin: 0;
    padding: 0;
    list-style: none;
}

.dx-aside-links li {
    margin: 0;
}

.dx-aside-links li + li {
    margin-top: 6px;
}

.dx-aside-links a,
.dx-aside-links a:visited {
    color: var(--dx-link);
    font-weight: 700;
    text-decoration: none;
}

.dx-aside-links a:hover {
    text-decoration: underline;
}

.dx-side a:focus-visible {
    outline: 2px solid var(--dx-focus);
    outline-offset: 2px;
}

/* Sidebar ad. Until Google fills the slot, the slot collapses and the QR
   code holds the box. The slot keeps its width so AdSense can size the ad. */
.dx-aside-ad {
    padding: 10px 12px 12px;
}

.dx-aside-ad-label {
    margin: 0 0 6px;
    color: var(--dx-meta);
    font-size: 11px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.dx-aside-ad-fallback,
.dx-aside-ad-fallback:visited {
    display: block;
    padding: 6px 0 2px;
    text-align: center;
    text-decoration: none;
}

.dx-aside-ad-fallback img {
    display: block;
    width: 120px;
    height: 120px;
    margin: 0 auto;
}

.dx-aside-ad-note {
    display: block;
    margin-top: 8px;
    color: var(--dx-meta);
    font-size: 12px;
}

.dx-aside-ad ins.adsbygoogle:not([data-ad-status="filled"]) {
    height: 0 !important;
    max-height: 0 !important;
    overflow: hidden !important;
}

.dx-aside-ad:not(:has(ins[data-ad-status="filled"])) .dx-aside-ad-label,
.dx-aside-ad:has(ins[data-ad-status="filled"]) .dx-aside-ad-fallback {
    display: none;
}

/* ── Header ────────────────────────────────────────────────────────── */
.hn-header {
    --hn-height: 40px;
    --hn-bg: #08233f;
    --hn-line: #0ea5e9;
    --hn-fg: #ffffff;
    --hn-fg-muted: #dbe8f3;
    --hn-link: #c7d5e2;
    --hn-active: #7dd3fc;
    --hn-icon-border: #0369a1;
    --hn-icon-glow: rgba(3, 105, 161, 0.16);
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    box-sizing: border-box;
    height: var(--hn-height);
    padding: 0 var(--dx-gutter);
    background: var(--hn-bg);
    border-bottom: 2px solid var(--hn-line);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.4;
}

html.dark .hn-header {
    --hn-bg: #0b1d33;
    --hn-icon-border: #7dd3fc;
    --hn-icon-glow: rgba(125, 211, 252, 0.16);
}

.hn-header *,
.hn-header *::before,
.hn-header *::after {
    box-sizing: border-box;
    border-radius: 0;
}

.hn-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    width: 100%;
    max-width: var(--dx-frame);
    height: 100%;
    margin: 0 auto;
}

.hn-header-left,
.hn-header-right {
    display: flex;
    align-items: center;
    min-width: 0;
}

.hn-header-left {
    gap: 10px;
}

.hn-header-right {
    gap: 12px;
}

/* Logo */
.hn-header .hn-logo,
.hn-header .hn-logo:visited {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: var(--hn-height);
    padding: 0 3px;
    color: var(--hn-fg);
    font-size: 15px;
    font-weight: 800;
    letter-spacing: -0.02em;
    text-decoration: none;
    transition: transform 0.2s ease;
}

.hn-header .hn-logo:hover {
    transform: scale(1.04);
    text-decoration: none;
}

.hn-logo-icon {
    display: grid;
    place-items: center;
    width: 18px;
    height: 18px;
    border: 2px solid var(--hn-icon-border);
    color: #08233f;
    background: #0ea5e9;
    box-shadow: 0 0 8px var(--hn-icon-glow);
    font-size: 9px;
    line-height: 1;
}

/* Primary navigation */
.hn-nav {
    display: flex;
    align-items: center;
    gap: 0;
}

.hn-header .hn-nav a,
.hn-header .hn-nav a:visited,
.hn-header .hn-nav .hn-admin-signout {
    position: relative;
    display: inline-flex;
    align-items: center;
    min-height: var(--hn-height);
    margin: 0;
    padding: 0 8px;
    color: var(--hn-link);
    background: transparent;
    border: 0;
    font: inherit;
    font-size: 13px;
    font-weight: 400;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.hn-header .hn-nav a:hover,
.hn-header .hn-nav .hn-admin-signout:hover {
    color: var(--hn-fg);
    background: rgba(255, 255, 255, 0.08);
    text-decoration: underline;
}

.hn-header .hn-nav a.active {
    color: var(--hn-fg);
    font-weight: 700;
    background: rgba(14, 165, 233, 0.1);
}

.hn-nav a.active::after {
    content: '';
    position: absolute;
    right: 8px;
    bottom: 0;
    left: 8px;
    height: 2px;
    background: var(--hn-active);
}

/* Search */
.hn-header-search {
    display: flex;
    align-items: center;
    width: min(26vw, 250px);
    min-width: 150px;
    margin: 0;
}

.hn-header-search-box {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    height: 28px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.28);
}

.hn-header-search-box:focus-within {
    background: #ffffff;
    border-color: #7dd3fc;
    box-shadow: 0 0 0 2px rgba(125, 211, 252, 0.35);
}

.hn-header-search-icon {
    position: absolute;
    left: 8px;
    flex-shrink: 0;
    color: var(--hn-fg-muted);
    opacity: 0.55;
    pointer-events: none;
}

.hn-header-search-box:focus-within .hn-header-search-icon {
    color: #526171;
}

.hn-header .hn-header-search-input {
    width: 100%;
    height: 26px;
    margin: 0;
    padding: 0 28px 0 27px;
    color: var(--hn-fg);
    background: transparent;
    border: 0;
    outline: 0;
    font: inherit;
    font-size: 13px;
    -webkit-appearance: none;
    appearance: none;
}

.hn-header-search-input::placeholder {
    color: var(--hn-fg-muted);
    opacity: 0.82;
}

.hn-header-search-input::-webkit-search-cancel-button {
    display: none;
}

.hn-header-search-box:focus-within .hn-header-search-input {
    color: #17212b;
}

.hn-header-search-box:focus-within .hn-header-search-input::placeholder {
    color: #526171;
}

.hn-header-search-hint {
    position: absolute;
    right: 6px;
    padding: 0 5px;
    color: var(--hn-fg-muted);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.3);
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 10px;
    line-height: 18px;
    opacity: 0.7;
    pointer-events: none;
}

.hn-header-search-box:focus-within .hn-header-search-hint {
    display: none;
}

/* Buttons: clear search, theme, menu */
.hn-header-search-close,
.hn-dark-toggle,
.hn-hamburger {
    display: inline-grid;
    place-items: center;
    min-width: 32px;
    min-height: 32px;
    margin: 0;
    padding: 0;
    color: var(--hn-fg);
    background: transparent;
    border: 1px solid transparent;
    font: inherit;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
}

.hn-header-search-close {
    position: absolute;
    right: 0;
    color: var(--hn-fg-muted);
    border: 0;
    opacity: 0.6;
}

.hn-header-search-close:hover {
    color: var(--hn-fg);
    opacity: 1;
}

.hn-header-search-box:focus-within .hn-header-search-close {
    color: #17212b;
}

.hn-dark-toggle:hover,
.hn-hamburger:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.22);
}

.hn-hamburger {
    display: none;
}

/* Phone menu */
.hn-mobile-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    padding: 6px 16px 12px;
    background: var(--hn-bg);
    border-bottom: 3px solid var(--hn-line);
    box-shadow: 0 8px 20px rgba(8, 35, 63, 0.25);
}

.hn-mobile-menu[hidden] {
    display: none;
}

.hn-header .hn-mobile-menu a,
.hn-header .hn-mobile-menu a:visited,
.hn-header .hn-mobile-menu .hn-admin-signout {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 44px;
    padding: 0 10px;
    color: var(--hn-fg-muted);
    background: transparent;
    border: 0;
    border-left: 3px solid transparent;
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.hn-header .hn-mobile-menu a:hover,
.hn-header .hn-mobile-menu a.active,
.hn-header .hn-mobile-menu .hn-admin-signout:hover {
    color: var(--hn-fg);
    background: rgba(255, 255, 255, 0.08);
    border-left-color: var(--hn-active);
    text-decoration: none;
}

/* Focus: amber reads on the navy bar in both themes. */
.hn-header :is(a, button, input):focus-visible {
    outline: 3px solid #fbbf24;
    outline-offset: -3px;
}

.hn-header .hn-header-search-input:focus-visible {
    outline: 0;
}

@media (max-width: 760px) {
    .hn-header {
        --hn-height: 44px;
        /* --dx-gutter is 12px here. */
    }

    .hn-header-inner {
        gap: 6px;
    }

    .hn-header-left {
        flex: 0 0 auto;
    }

    .hn-header-right {
        flex: 1 1 auto;
        justify-content: flex-end;
        gap: 4px;
        margin-left: auto;
    }

    .hn-nav {
        display: none;
    }

    .hn-header-search {
        flex: 1 1 120px;
        width: auto;
        min-width: 0;
    }

    .hn-header-search-box {
        height: 34px;
    }

    .hn-header .hn-header-search-input {
        height: 32px;
        padding-right: 36px;
        /* 16px stops iOS from zooming into the field. */
        font-size: 16px;
    }

    .hn-header-search-hint {
        display: none;
    }

    .hn-header-search-close,
    .hn-dark-toggle,
    .hn-hamburger {
        min-width: 40px;
        min-height: 40px;
    }

    .hn-dark-toggle,
    .hn-hamburger {
        flex: 0 0 40px;
    }

    .hn-hamburger {
        display: inline-grid;
    }
}

@media (min-width: 761px) {
    .hn-mobile-menu {
        display: none;
    }
}

@media (forced-colors: active) {
    .hn-header {
        border-color: CanvasText;
    }
}
