/* ==========================================================
   After the Beep — CSS-Drawn Retro Answering Machine
   Flat retro style, 70s colour palette, clean geometry
   ========================================================== */

/* --- Reset & Base --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    /* 70s colour palette */
    --body-bg: #2c2416;
    --machine-body: #8b6914;
    --machine-body-dark: #705510;
    --machine-trim: #c4a44a;
    --metal: #b8b0a0;
    --metal-dark: #8a8070;
    --metal-light: #d0c8b8;
    --panel-bg: #3a3530;
    --panel-border: #2a2520;
    --lcd-bg: #0c1a08;
    --lcd-text: #cc8800;
    --lcd-glow: #cc880066;
    --btn-bg: #2a2520;
    --btn-border: #1a1510;
    --btn-text: #d0c8b8;
    --btn-hover: #3a3530;
    --rec-red: #cc3333;
    --rec-glow: #ff444466;
    --indicator-off: #5a3800;
    --indicator-on: #ff9900;
    --indicator-glow: #ff990066;
    --speaker-slot: #3a3530;
    --text-primary: #e8dcc8;
    --text-muted: #a09080;
}

body {
    background: var(--body-bg);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    overflow-x: hidden;
    color: var(--text-primary);
}

/* --- Scene --- */
.scene {
    padding: 2rem;
    width: 100%;
    max-width: 860px;
}

/* --- Site Header --- */
.site-header {
    text-align: center;
    margin-bottom: 2rem;
}

.site-title {
    font-size: clamp(24px, 5vw, 40px);
    font-weight: bold;
    letter-spacing: 0.15em;
    color: var(--machine-trim);
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}

.site-tagline {
    font-size: clamp(13px, 2vw, 17px);
    color: var(--text-muted);
    line-height: 1.5;
    max-width: 520px;
    margin: 0 auto;
}

/* --- Machine Body --- */
.machine {
    background: var(--machine-body);
    border-radius: 14px;
    padding: 32px;
    position: relative;
    box-shadow:
        0 2px 0 var(--machine-trim),
        0 10px 30px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    border: 3px solid var(--machine-body-dark);
    user-select: none;
    -webkit-user-select: none;
}

/* Subtle top bevel */
.machine::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0.15),
        transparent
    );
    border-radius: 14px 14px 0 0;
    pointer-events: none;
}

/* --- Top Section: Display + Indicator --- */
.machine-top {
    margin-bottom: 20px;
}

.display-area {
    display: flex;
    align-items: center;
    gap: 24px;
}

/* LCD Bezel */
.lcd-bezel {
    flex: 1;
    background: var(--metal);
    border-radius: 6px;
    padding: 6px;
    box-shadow:
        inset 0 1px 3px rgba(0, 0, 0, 0.3),
        0 1px 0 var(--metal-light);
}

.lcd-screen {
    background: var(--lcd-bg);
    border-radius: 3px;
    padding: 18px 24px;
    text-align: center;
    position: relative;
    overflow: hidden;
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Scanline overlay */
.lcd-screen::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 2px,
        rgba(0, 0, 0, 0.2) 2px,
        rgba(0, 0, 0, 0.2) 4px
    );
    pointer-events: none;
}

#lcd-text {
    font-family: "Courier New", "Lucida Console", monospace;
    font-size: clamp(16px, 3vw, 26px);
    font-weight: bold;
    letter-spacing: 0.2em;
    color: var(--lcd-text);
    text-shadow:
        0 0 8px var(--lcd-glow),
        0 0 16px var(--lcd-glow);
    white-space: nowrap;
    line-height: 1;
    position: relative;
    z-index: 1;
}

/* Indicator light area */
.indicator-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.indicator-light {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--indicator-off);
    border: 2px solid var(--metal-dark);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.4);
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

.indicator-light.lit {
    background: radial-gradient(
        circle at 40% 35%,
        #ffcc44 0%,
        var(--indicator-on) 50%,
        #cc6600 100%
    );
    box-shadow:
        inset 0 1px 2px rgba(255, 255, 255, 0.3),
        0 0 10px 3px var(--indicator-glow),
        0 0 24px 6px rgba(255, 153, 0, 0.2);
    animation: blink 1.2s ease-in-out infinite;
}

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

.indicator-label {
    font-size: 10px;
    font-weight: bold;
    color: var(--machine-trim);
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

/* --- Cassette Window --- */
.cassette-window {
    background: var(--metal);
    border-radius: 6px;
    padding: 5px;
    margin-bottom: 20px;
    box-shadow:
        inset 0 1px 3px rgba(0, 0, 0, 0.3),
        0 1px 0 var(--metal-light);
}

.cassette-inner {
    background: #e8e0d0;
    border-radius: 3px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    min-height: 56px;
}

.reel {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #d0c8b8;
    border: 2px solid #b8b0a0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.reel-hub {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #8a8070;
    border: 1px solid #706858;
}

/* Spin animation for recording/playing state */
.machine.is-recording .reel {
    animation: spin 1.5s linear infinite;
}

.machine.is-playing .reel {
    animation: spin 2s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.tape-label {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 9px;
    font-weight: bold;
    letter-spacing: 0.25em;
    color: #8a8070;
    text-transform: uppercase;
    white-space: nowrap;
}

/* --- Control Panel --- */
.control-panel {
    background: var(--panel-bg);
    border-radius: 6px;
    padding: 20px;
    display: flex;
    align-items: stretch;
    gap: 16px;
    margin-bottom: 20px;
    border: 1px solid var(--panel-border);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* --- Buttons --- */
.btn {
    background: var(--btn-bg);
    color: var(--btn-text);
    border: 1px solid var(--btn-border);
    border-radius: 6px;
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-weight: bold;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow:
        0 3px 0 var(--btn-border),
        0 4px 8px rgba(0, 0, 0, 0.3);
    transition:
        transform 0.08s ease,
        box-shadow 0.08s ease,
        background 0.15s ease;
    text-align: center;
    line-height: 1;
    flex: 1;
    font-size: clamp(16px, 3vw, 22px);
    padding: 24px 20px;
}

.btn:active:not(:disabled) {
    transform: translateY(3px);
    box-shadow:
        0 0 0 var(--btn-border),
        0 1px 2px rgba(0, 0, 0, 0.3);
}

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

/* Play button */
.btn-play:hover:not(:disabled) {
    background: var(--btn-hover);
}

.btn-play.active {
    background: #444;
}

/* Record button — red dot accent */
.btn-rec {
    position: relative;
    padding-left: 36px;
}

.btn-rec::before {
    content: "";
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--rec-red);
    box-shadow: 0 0 4px var(--rec-glow);
}

.btn-rec:hover:not(:disabled) {
    background: var(--btn-hover);
}

.btn-rec.recording {
    background: #4a1515;
    box-shadow:
        0 3px 0 var(--btn-border),
        0 0 16px var(--rec-glow);
}

.btn-rec.recording::before {
    animation: rec-blink 0.8s ease-in-out infinite;
}

@keyframes rec-blink {
    0%,
    100% {
        background: var(--rec-red);
        box-shadow: 0 0 6px var(--rec-glow);
    }
    50% {
        background: #ff6666;
        box-shadow: 0 0 14px #ff444488;
    }
}

/* --- Speaker Grille --- */
.speaker-grille {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 10px 48px;
    margin-bottom: 14px;
}

.grille-slot {
    height: 2px;
    background: var(--speaker-slot);
    border-radius: 1px;
    box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.3);
}

/* Animate grille during playback */
.machine.is-playing .grille-slot {
    animation: grille-pulse 0.15s ease-in-out infinite alternate;
}

.machine.is-playing .grille-slot:nth-child(odd) {
    animation-delay: 0.05s;
}

@keyframes grille-pulse {
    from {
        opacity: 0.6;
    }
    to {
        opacity: 1;
    }
}

/* --- Brand Label --- */
.brand-label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0 4px;
}

.brand-name {
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 0.3em;
    color: var(--machine-trim);
    text-transform: uppercase;
}

.brand-model {
    font-size: 10px;
    letter-spacing: 0.15em;
    color: var(--machine-body-dark);
}

/* --- Responsive --- */
@media (max-width: 500px) {
    .scene {
        padding: 1rem 0.5rem;
    }

    .machine {
        padding: 20px;
        border-radius: 10px;
    }

    .control-panel {
        flex-direction: column;
    }

    .btn-rec {
        padding-left: 36px;
    }

    .cassette-inner {
        gap: 24px;
    }
}
