/*
 * Cypher Challenge II: Broken Circuit
 *
 * Forked from cipher-challenge/style.css and kept deliberately close to it: this
 * is the same universe and should feel like it. The differences are that this
 * copy is born responsive rather than having it retrofitted, and that it carries
 * the shared components the second half needs (panels, buttons, tool blocks) so
 * that fourteen stages do not each invent their own.
 *
 * If a stage needs something only that stage needs, keep it inline on the page.
 * If two stages need it, it belongs here.
 */

:root {
    --green: #39ff14;
    --green-dim: #1a8c00;
    --green-dark: #0d4d00;
    --bg: #060a06;
    --bg-panel: #0b110b;
    --border: #1f3d1f;
    --error: #ff4444;
    --amber: #ffb000;
    --font: 'Courier New', Courier, monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg);
    color: var(--green);
    font-family: var(--font);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 40px 20px;
}

.terminal {
    width: 100%;
    max-width: 800px;
}

/* ---------------------------------------------------------------- header */

.header {
    font-size: 1.4rem;
    font-weight: bold;
    text-shadow: 0 0 10px var(--green);
    border-bottom: 1px solid var(--border);
    padding-bottom: 16px;
    margin-bottom: 32px;
    letter-spacing: 2px;
}

.header .sub {
    display: block;
    font-size: 0.75rem;
    font-weight: normal;
    color: var(--green-dim);
    letter-spacing: 4px;
    margin-top: 8px;
}

/* ---------------------------------------------------------------- text */

.section {
    margin-bottom: 32px;
}

.label {
    color: var(--green-dim);
    font-size: 0.8rem;
    margin-bottom: 10px;
    letter-spacing: 1px;
}

p {
    line-height: 1.7;
    color: #aad4aa;
}

p + p {
    margin-top: 14px;
}

a {
    color: var(--green);
}

ul {
    list-style: none;
    padding-left: 0;
}

ul li {
    color: #aad4aa;
    padding: 4px 0;
    line-height: 1.7;
}

ul li::before {
    content: '> ';
    color: var(--green-dim);
}

.stage-badge {
    display: inline-block;
    border: 1px solid var(--green-dim);
    padding: 2px 10px;
    font-size: 0.75rem;
    color: var(--green-dim);
    letter-spacing: 2px;
    margin-bottom: 12px;
}

.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 32px 0;
}

/* ---------------------------------------------------------------- ciphertext */

.cipher-box {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    padding: 24px;
    font-size: 1.3rem;
    letter-spacing: 4px;
    word-spacing: 12px;
    text-shadow: 0 0 8px var(--green);
    line-height: 2;
    word-break: break-all;
}

/* For blocks that are long or dense (binary, hex, coordinate pairs). Use this
   class instead of an inline font-size override, so the mobile rules below can
   still reach it. Inline styles beat media queries; that bit us in v1. */
.cipher-box.dense {
    font-size: 0.95rem;
    letter-spacing: 1px;
    word-spacing: 6px;
    line-height: 2.2;
    /* Dense blocks are groups separated by spaces (hex pairs, binary octets).
       The base rule's break-all would split a group across lines and make it
       unreadable, so wrap at the spaces and only break a token if it genuinely
       cannot fit. */
    word-break: normal;
    overflow-wrap: break-word;
}

/* ---------------------------------------------------------------- field note */

.field-note {
    border-left: 2px solid var(--green-dark);
    padding-left: 18px;
    margin-top: 8px;
}

.field-note em {
    color: #aad4aa;
}

/* ---------------------------------------------------------------- panels */

/* Generic container for an interactive tool: sliders, inspectors, grids. */
.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    padding: 20px 24px;
    margin: 16px 0;
}

.panel .panel-label {
    color: var(--green-dim);
    font-size: 0.75rem;
    letter-spacing: 2px;
    display: block;
    margin-bottom: 14px;
}

.mono-out {
    font-family: var(--font);
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--green);
    padding: 12px 14px;
    width: 100%;
    font-size: 0.95rem;
    line-height: 1.8;
    word-break: break-all;
    min-height: 44px;
}

textarea.mono-out {
    resize: vertical;
}

/* ---------------------------------------------------------------- controls */

.btn {
    display: inline-block;
    background: transparent;
    border: 1px solid var(--green-dim);
    color: var(--green);
    font-family: inherit;
    font-size: 1rem;
    letter-spacing: 3px;
    padding: 14px 36px;
    text-decoration: none;
    cursor: pointer;
}

.btn:hover {
    background: var(--bg-panel);
    border-color: var(--green);
    text-shadow: 0 0 8px var(--green);
}

.btn-primary {
    border-color: var(--green);
    box-shadow: 0 0 16px rgba(57, 255, 20, 0.15);
}

input[type="text"],
input[type="number"] {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--green);
    font-family: inherit;
    font-size: 1rem;
    padding: 10px 12px;
}

input[type="range"] {
    width: 100%;
    accent-color: var(--green);
}

/* ---------------------------------------------------------------- effects */

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.blink {
    animation: blink 1s step-end infinite;
}

@keyframes scanline {
    0% { top: -10%; }
    100% { top: 110%; }
}

body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(transparent, rgba(57, 255, 20, 0.06), transparent);
    animation: scanline 6s linear infinite;
    pointer-events: none;
    z-index: 999;
}

@media (prefers-reduced-motion: reduce) {
    .blink,
    body::after {
        animation: none;
    }
}

/* ---------------------------------------------------------------- phones */

@media (max-width: 768px) {
    body {
        padding: 24px 14px;
    }

    .header {
        font-size: 1.1rem;
        letter-spacing: 1px;
        padding-bottom: 12px;
        margin-bottom: 24px;
    }

    .header .sub {
        letter-spacing: 2px;
    }

    .section {
        margin-bottom: 24px;
    }

    .divider {
        margin: 24px 0;
    }

    .cipher-box {
        font-size: 1rem;
        letter-spacing: 2px;
        word-spacing: 6px;
        padding: 16px;
        line-height: 1.9;
    }

    .cipher-box.dense {
        font-size: 0.85rem;
        letter-spacing: 0;
        word-spacing: 4px;
    }

    .panel {
        padding: 16px 14px;
    }

    .field-note {
        padding-left: 12px;
    }

    .btn {
        font-size: 0.95rem;
        letter-spacing: 2px;
        padding: 12px 24px;
    }

    p,
    ul li {
        line-height: 1.6;
    }
}

/* ---------------------------------------------------------------- terminal */

/* Used by the field terminal on stages 12 and 14. Lives here rather than on
   each page so the two cannot drift apart. */
.ft-note {
    color: var(--green-dim);
    font-size: 0.78rem;
    line-height: 1.7;
    margin-bottom: 10px;
}

.ft-code {
    width: 100%;
    min-height: 150px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--green);
    font-family: var(--font);
    font-size: 0.92rem;
    line-height: 1.6;
    padding: 12px;
    resize: vertical;
    tab-size: 2;
}

.ft-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin: 10px 0;
}

.ft-bar button {
    background: transparent;
    border: 1px solid var(--green-dim);
    color: var(--green);
    font-family: var(--font);
    font-size: 0.85rem;
    letter-spacing: 2px;
    padding: 9px 22px;
    cursor: pointer;
}

.ft-bar button:hover {
    border-color: var(--green);
    text-shadow: 0 0 8px var(--green);
}

.ft-status { font-size: 0.75rem; letter-spacing: 1px; color: var(--green-dim); }
.ft-status.ok { color: var(--green); }
.ft-status.bad { color: var(--error); }
.ft-status.busy { color: var(--amber); }

.ft-out {
    background: var(--bg);
    border: 1px solid var(--border);
    min-height: 90px;
    max-height: 300px;
    overflow-y: auto;
    padding: 10px 12px;
    font-size: 0.88rem;
    line-height: 1.7;
    color: #aad4aa;
    word-break: break-all;
}

.ft-out .ft-err { color: var(--error); }
.ft-out .ft-warn { color: var(--amber); }

/* ---------------------------------------------------------------- scrollbars */

/* Several panels scroll: the wordbook, the character inspector, the terminal
   output, the repeat tables. The default Windows scrollbar is a wide grey slab
   that fights the whole look, so make it thin and quiet everywhere. Firefox uses
   the two standard properties; Chrome needs the webkit pseudo-elements. */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--green-dark) transparent;
}

::-webkit-scrollbar {
    width: 9px;
    height: 9px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--green-dark);
    border-radius: 5px;
    border: 2px solid transparent;
    background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--green-dim);
    background-clip: content-box;
}

::-webkit-scrollbar-corner {
    background: transparent;
}

/* Anything that scrolls gets breathing room on the right so the text never
   runs under the scrollbar, and a little at the bottom so the last line is not
   jammed against the edge. */
.scrolls,
.ft-out,
.wordlist,
.scroll {
    padding-right: 16px;
    padding-bottom: 12px;
}

/* Native dropdowns. The popup list itself is drawn by the operating system and
   cannot be styled, but the closed control can at least match everything else. */
select {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--green);
    font-family: var(--font);
    padding: 8px 10px;
}

select:focus {
    outline: 1px solid var(--green-dim);
}
