/* Bunker Base voice page: board-formed concrete, Create-style brass, one hatch. */
:root {
    --concrete: #2c3135;
    --steel: #3d454b;
    --steel-raised: #4a535a;
    --seam: #59636a;
    --door: #262b2e;
    --brass: #c8963e;
    --brass-hot: #e7b35a;
    --verdigris: #6fb39c;
    --signal: #e0644c;
    --paint: #ece6d8;
    --paint-dim: #aaa698;

    --font-stencil: "Big Shoulders Stencil Display", "Arial Narrow", Impact, sans-serif;
    --font-condensed: "Barlow Semi Condensed", "Arial Narrow", sans-serif;
    --font-body: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;

    --icon-mic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='9' y='2' width='6' height='12' rx='3'/%3E%3Cpath d='M5 10v1a7 7 0 0 0 14 0v-1M12 18v4M8 22h8'/%3E%3C/svg%3E");
    --icon-mic-off: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='9' y='2' width='6' height='12' rx='3'/%3E%3Cpath d='M5 10v1a7 7 0 0 0 14 0v-1M12 18v4M8 22h8M3 3l18 18'/%3E%3C/svg%3E");
    --icon-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23aaa698' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");

    color-scheme: dark;
}

*, *::before, *::after {
    box-sizing: border-box;
}

[hidden],
.dev-hidden {
    display: none !important;
}

html {
    height: 100%;
}

body {
    margin: 0;
    min-height: 100%;
    display: flex;
    flex-direction: column;
    color: var(--paint);
    font: 400 1.0625rem/1.5 var(--font-body);
    -webkit-font-smoothing: antialiased;
    background-color: var(--concrete);
    /* Formwork: a soft work light, tie holes, then horizontal and vertical panel seams. */
    background-image:
        radial-gradient(ellipse 70% 55% at 50% 36%, rgba(236, 230, 216, 0.07), transparent 70%),
        radial-gradient(circle at 60px 60px, rgba(0, 0, 0, 0.34) 0 2.5px, rgba(255, 255, 255, 0.05) 3px, transparent 3.6px),
        linear-gradient(rgba(0, 0, 0, 0.17) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 0, 0, 0.12) 1px, transparent 1px);
    background-size: 100% 100%, 120px 120px, 240px 120px, 240px 120px;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    opacity: 0.3;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

button,
select,
input {
    font: inherit;
}

button:focus-visible,
select:focus-visible,
input:focus-visible {
    outline: 3px solid var(--brass-hot);
    outline-offset: 3px;
}

kbd {
    font: 600 0.95em/1 var(--font-condensed);
    padding: 0.15em 0.45em 0.2em;
    border-radius: 4px;
    background: var(--steel-raised);
    border-bottom: 2px solid #1f2326;
    color: var(--paint);
    white-space: nowrap;
}

/* Masthead: the name, painted on the wall. */
.masthead {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.75rem;
    padding: 1.25rem 1.5rem 0;
}

.brand {
    font: 800 1.5rem/1 var(--font-stencil);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--brass);
}

.brand-sub {
    font: 500 0.9375rem/1 var(--font-condensed);
    color: var(--paint-dim);
}

.station {
    flex: 1;
    width: 100%;
    max-width: 27rem;
    margin: 0 auto;
    padding: 2rem 1rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    text-align: center;
}

/* Each part belongs to one or two states. */
.identity,
.steps,
.controls,
.devices,
.join,
.warning,
.hatch-slot,
.hatch-stamp,
.hatch-glyph {
    display: none;
}

[data-state="connected"] .identity,
[data-state="connected"] .controls {
    display: flex;
}

[data-state="nolink"] .steps {
    display: flex;
}

[data-state="ready"] .devices {
    display: grid;
}

[data-state="ready"] .join,
[data-state="connected"] .join,
[data-state="connected"] .hatch-slot,
[data-state="nolink"] .hatch-stamp,
[data-state="ready"].mic-blocked .warning {
    display: block;
}

[data-state="loading"] .hatch-glyph,
[data-state="ready"] .hatch-glyph,
[data-state="connecting"] .hatch-glyph,
[data-state="ended"] .hatch-glyph {
    display: block;
}

/* The hatch */
.hatch {
    --ring: var(--seam);
    position: relative;
    width: 15rem;
    aspect-ratio: 1;
    flex-shrink: 0;
}

[data-state="ready"] .hatch,
[data-state="connecting"] .hatch {
    --ring: var(--brass);
}

[data-state="connected"] .hatch {
    --ring: var(--verdigris);
}

[data-state] .hatch.active {
    --ring: var(--brass-hot);
}

body.muted[data-state="connected"] .hatch,
[data-state="ended"] .hatch {
    --ring: var(--signal);
}

.hatch-frame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
    filter: drop-shadow(0 18px 28px rgba(0, 0, 0, 0.45));
}

.hf-rim {
    fill: var(--steel);
    stroke: #1c2023;
    stroke-width: 2;
}

.hf-recess {
    fill: #30373c;
    stroke: rgba(0, 0, 0, 0.45);
    stroke-width: 2;
}

.hf-bolts circle {
    fill: #6b747b;
    stroke: #22272a;
    stroke-width: 1.5;
}

.hf-ring {
    fill: none;
    stroke: var(--ring);
    stroke-width: 6;
    transform-origin: 120px 120px;
    transition: stroke 0.15s ease, filter 0.15s ease;
}

/* The ring draws itself once, when the page opens; later states never replay it. */
[data-state="nolink"] .hf-ring,
[data-state="ready"] .hf-ring {
    animation: hatch-unlock 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.hf-door {
    fill: var(--door);
    stroke: #1b1f22;
    stroke-width: 2;
}

.hf-groove {
    fill: none;
    stroke: rgba(255, 255, 255, 0.05);
    stroke-width: 1.5;
}

[data-state="connecting"] .hf-ring {
    stroke-dasharray: 6 4;
    animation: hatch-turn 2.4s linear infinite;
}

[data-state] .hatch.active .hf-ring {
    filter: drop-shadow(0 0 7px var(--brass-hot));
}

/* Speaking: the ring sends out a pulse while the microphone carries voice. */
.hatch::after {
    content: "";
    position: absolute;
    inset: 6%;
    border-radius: 50%;
    border: 3px solid var(--brass-hot);
    opacity: 0;
    pointer-events: none;
}

[data-state] .hatch.active::after {
    animation: hatch-pulse 1.1s ease-out infinite;
}

[data-state="ended"] .hatch-frame {
    filter: drop-shadow(0 18px 28px rgba(0, 0, 0, 0.45)) saturate(0.6);
}

.hatch-face {
    position: absolute;
    inset: 17%;
    display: grid;
    place-items: center;
    pointer-events: none;
}

.hatch-stamp {
    font: 800 2.5rem/1 var(--font-stencil);
    color: var(--paint);
    opacity: 0.9;
}

.hatch-glyph {
    width: 3.5rem;
    height: 3.5rem;
    background: var(--paint);
    -webkit-mask: var(--icon-mic) center / contain no-repeat;
    mask: var(--icon-mic) center / contain no-repeat;
}

[data-state="loading"] .hatch-glyph,
[data-state="connecting"] .hatch-glyph {
    opacity: 0.55;
}

[data-state="ended"] .hatch-glyph {
    background: var(--signal);
    -webkit-mask-image: var(--icon-mic-off);
    mask-image: var(--icon-mic-off);
}

.hatch-core {
    position: absolute;
    inset: 17%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0 1.25rem;
    border: 0;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 32%, #31383d, var(--door) 72%);
    color: var(--paint);
    font: 600 0.9375rem/1.15 var(--font-condensed);
    cursor: pointer;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    transition: background 0.15s ease, color 0.15s ease;
}

.hatch-core::before {
    content: "";
    width: 3rem;
    height: 3rem;
    background: currentColor;
    -webkit-mask: var(--icon-mic) center / contain no-repeat;
    mask: var(--icon-mic) center / contain no-repeat;
}

.hatch-core:hover {
    background: radial-gradient(circle at 50% 32%, #394146, #2a3033 72%);
}

.hatch-core:active {
    transform: scale(0.985);
}

.hatch-core.muted {
    color: var(--signal);
}

.hatch-core.muted::before {
    -webkit-mask-image: var(--icon-mic-off);
    mask-image: var(--icon-mic-off);
}

.hatch-core-ptt.active {
    color: var(--brass-hot);
}

/* Player */
.identity {
    align-items: center;
    gap: 0.875rem;
    padding: 0.5rem 1rem 0.5rem 0.5rem;
    text-align: left;
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 6px;
}

.identity-head {
    position: relative;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    background: var(--steel);
}

.identity-head img {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
}

#playerInitial {
    display: none;
}

.no-head .identity-head img {
    display: none;
}

.no-head #playerInitial {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font: 800 1.75rem/1 var(--font-stencil);
    color: var(--brass);
}

.identity-text {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.identity-text strong {
    font: 600 1.125rem/1.2 var(--font-condensed);
}

.identity-status {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--paint-dim);
}

.lamp {
    width: 0.625rem;
    height: 0.625rem;
    flex-shrink: 0;
    border-radius: 50%;
    background: #4b5359;
    box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.5);
    transition: background 0.12s ease, box-shadow 0.12s ease;
}

.lamp-on,
.receiving .reception .lamp {
    background: var(--verdigris);
    box-shadow: 0 0 8px rgba(111, 179, 156, 0.75);
}

/* Words */
.briefing {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.625rem;
}

.title {
    margin: 0;
    font: 800 2.375rem/1.02 var(--font-stencil);
    letter-spacing: 0.01em;
    text-wrap: balance;
}

.lead {
    margin: 0;
    max-width: 34ch;
    color: var(--paint-dim);
    text-wrap: pretty;
}

.lead:empty,
.footnote:empty {
    display: none;
}

.steps {
    flex-direction: column;
    gap: 0.875rem;
    width: 100%;
    max-width: 22rem;
    margin: 0.75rem 0 0;
    padding: 0;
    list-style: none;
    counter-reset: step;
    text-align: left;
}

.steps li {
    counter-increment: step;
    display: grid;
    grid-template-columns: 2.25rem 1fr;
    align-items: baseline;
    gap: 0.5rem;
}

.steps li::before {
    content: counter(step);
    font: 800 2rem/1 var(--font-stencil);
    color: var(--brass);
    text-align: center;
}

.footnote {
    margin: 0;
    max-width: 40ch;
    text-wrap: balance;
    font-size: 0.875rem;
    color: var(--paint-dim);
}

/* Connected controls */
.controls {
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    width: 100%;
}

.mode {
    display: inline-flex;
    padding: 3px;
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
}

.mode button {
    padding: 0.625rem 0.875rem;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--paint-dim);
    font: 500 0.9375rem/1 var(--font-condensed);
    cursor: pointer;
}

.mode button:hover {
    color: var(--paint);
}

.mode button[aria-pressed="true"] {
    background: var(--steel-raised);
    color: var(--paint);
    box-shadow: inset 0 -2px 0 var(--brass);
}

.mode-select {
    display: none;
}

.ptt-settings {
    width: 100%;
    padding: 0.875rem 1rem;
    text-align: left;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 6px;
}

.ptt-binding {
    margin: 0 0 0.625rem;
    font-size: 0.9375rem;
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.btn-quiet {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--seam);
    border-radius: 5px;
    background: var(--steel);
    color: var(--paint);
    font: 500 0.9375rem/1.1 var(--font-condensed);
    cursor: pointer;
}

.btn-quiet:hover {
    background: var(--steel-raised);
}

.btn-quiet:disabled {
    opacity: 0.6;
    cursor: default;
}

.check {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-top: 0.75rem;
    font-size: 0.875rem;
    color: var(--paint-dim);
    cursor: pointer;
}

.check input {
    margin-top: 0.2rem;
    accent-color: var(--brass);
}

.reception {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-size: 0.9375rem;
    color: var(--paint-dim);
}

.receiving .reception {
    color: var(--paint);
}

/* Devices, before joining */
.devices {
    gap: 0.75rem;
    width: 100%;
    text-align: left;
}

.device {
    display: grid;
    gap: 0.3rem;
    font: 500 0.875rem/1.2 var(--font-condensed);
    color: var(--paint-dim);
}

.device select {
    width: 100%;
    padding: 0.625rem 2.25rem 0.625rem 0.75rem;
    border: 1px solid var(--seam);
    border-radius: 5px;
    background: var(--steel) var(--icon-chevron) no-repeat right 0.75rem center / 0.875rem;
    color: var(--paint);
    font: 400 1rem/1.3 var(--font-body);
    appearance: none;
    -webkit-appearance: none;
}

.device select:disabled {
    opacity: 0.7;
}

.no-output-choice .device-output {
    display: none;
}

.warning {
    margin: 0;
    padding: 0.75rem 0.875rem;
    border-left: 3px solid var(--signal);
    background: rgba(224, 100, 76, 0.1);
    font-size: 0.9375rem;
}

/* Join / leave */
.join {
    width: 100%;
}

.btn-primary {
    width: 100%;
    min-height: 3.25rem;
    border: 0;
    border-radius: 5px;
    background: var(--brass);
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25);
    color: #201a10;
    font: 600 1.1875rem/1 var(--font-condensed);
    cursor: pointer;
}

.btn-primary:hover {
    background: var(--brass-hot);
}

.btn-primary:active {
    transform: translateY(1px);
}

.btn-primary:disabled {
    opacity: 0.55;
    cursor: progress;
}

[data-state="connected"] .btn-primary {
    min-height: 2.75rem;
    border: 1px solid var(--seam);
    background: transparent;
    box-shadow: none;
    color: var(--paint-dim);
    font-size: 1rem;
}

[data-state="connected"] .btn-primary:hover {
    border-color: var(--signal);
    color: var(--paint);
}

.join-status {
    display: none;
}

/* Full-screen push-to-talk */
.ptt-overlay {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    padding: 1rem;
    background: var(--concrete);
}

.ptt-overlay.visible {
    display: flex;
}

.ptt-overlay-hold {
    width: min(70vmin, 26rem);
    aspect-ratio: 1;
    border: 10px solid var(--seam);
    border-radius: 50%;
    background: var(--door);
    color: var(--paint);
    font: 800 2rem/1.1 var(--font-stencil);
    cursor: pointer;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.ptt-overlay-hold.active {
    border-color: var(--brass-hot);
    color: var(--brass-hot);
    box-shadow: 0 0 40px rgba(231, 179, 90, 0.35);
}

.credits {
    padding: 1rem;
    text-align: center;
    font-size: 0.8125rem;
    color: rgba(170, 166, 152, 0.75);
}

@keyframes hatch-unlock {
    from {
        stroke-dasharray: 0 100;
    }
    to {
        stroke-dasharray: 100 0;
    }
}

@keyframes hatch-turn {
    to {
        transform: rotate(360deg);
    }
}

@keyframes hatch-pulse {
    from {
        opacity: 0.55;
        transform: scale(0.92);
    }
    to {
        opacity: 0;
        transform: scale(1.22);
    }
}

@media (max-width: 480px) {
    .masthead {
        padding: 1rem 1rem 0;
    }

    .station {
        gap: 1.25rem;
        padding: 1.5rem 1rem;
    }

    .hatch {
        width: 13rem;
    }

    .title {
        font-size: 2rem;
    }

    .mode button {
        padding: 0.625rem;
        font-size: 0.875rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    [data-state="nolink"] .hf-ring,
    [data-state="ready"] .hf-ring,
    [data-state="connecting"] .hf-ring {
        animation: none;
    }

    [data-state] .hatch.active::after {
        animation: none;
        opacity: 0.5;
        transform: scale(1.06);
    }
}
