/* ============================================================
 * HIIT Workout Tracker — "hackerman" theme
 * Heavily inspired by radio.omarchy.org (green theme):
 * near-black green-tinted background, phosphor-green accent,
 * 1px terminal borders, square corners, JetBrains Mono UI with
 * VT323 LCD readouts, uppercase micro-labels, scanlines.
 * ============================================================ */
:root {
    --bg: #0a0b0a;
    --fg: #e7e6e0;
    --ac: #5ef2a0;
    --ac-hi: #8ef6bd;
    --ac-fg: #070707;
    --bd: #23261f;
    --bd-f: #151713;
    --c2: #7d7d79;
    --c3: #4c4d4a;
    --row-on: #14271c;
    --row-hov: #191a19;
    --trk: #2b2c2a;
    --lcd: #050605;
    --g1: #36885a;
    --g2: #276040;
    --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --lcd-font: 'VT323', 'JetBrains Mono', ui-monospace, monospace;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--mono);
    background:
        radial-gradient(1200px 600px at 50% -10%, rgba(94, 242, 160, 0.06), transparent 60%),
        var(--bg);
    color: var(--fg);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizelegibility;
}

/* CRT scanline overlay */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 999;
    pointer-events: none;
    background: repeating-linear-gradient(180deg, rgba(0, 0, 0, 0.42) 0 2px, transparent 2px 4px);
    opacity: 0.45;
}

::selection {
    background: var(--ac);
    color: var(--ac-fg);
}

:focus-visible {
    outline: 2px solid var(--ac);
    outline-offset: 1px;
}

/* App Container */
.app-container {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    border-left: 1px solid var(--bd);
    border-right: 1px solid var(--bd);
}

/* Header — terminal bar */
.header {
    padding: 20px;
    text-align: center;
    background: var(--bg);
    border-bottom: 1px solid var(--bd);
}

.header h1 {
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0.34em;
    text-transform: uppercase;
    text-indent: 0.34em;
    margin-bottom: 15px;
    color: var(--fg);
}

.header h1::before {
    content: "> ";
    color: var(--ac);
}

.header h1::after {
    content: "_";
    color: var(--ac);
    animation: blink 1.4s step-end infinite;
}

.day-selector {
    display: flex;
    justify-content: center;
    gap: 0;
    border: 1px solid var(--bd);
    width: fit-content;
    margin: 0 auto;
}

.day-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 0;
    background: transparent;
    color: var(--c2);
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.day-btn + .day-btn {
    border-left: 1px solid var(--bd);
}

.day-btn.active {
    background: var(--ac);
    color: var(--ac-fg);
    box-shadow: none;
}

.day-btn:hover {
    transform: none;
    box-shadow: none;
    color: var(--fg);
    background: var(--row-hov);
}

.day-btn.active:hover {
    color: var(--ac-fg);
    background: var(--ac-hi);
}

/* Program & Rounds Settings */
.settings-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
}

.settings-group {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0;
    flex-wrap: wrap;
    border: 1px solid var(--bd);
}

.settings-label {
    font-size: 9px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.22em;
    color: var(--c2);
    padding: 0 10px;
    border-right: 1px solid var(--bd);
    align-self: stretch;
    display: flex;
    align-items: center;
}

.program-btn,
.rounds-btn {
    padding: 7px 14px;
    border: none;
    border-radius: 0;
    background: transparent;
    color: var(--c2);
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.program-btn + .program-btn,
.rounds-btn + .rounds-btn,
.settings-label + .program-btn,
.settings-label + .rounds-btn {
    border-left: 1px solid var(--bd);
}

.program-btn.active,
.rounds-btn.active {
    background: var(--ac);
    color: var(--ac-fg);
    box-shadow: none;
}

.program-btn:hover,
.rounds-btn:hover {
    transform: none;
    box-shadow: none;
    color: var(--fg);
    background: var(--row-hov);
}

.program-btn.active:hover,
.rounds-btn.active:hover {
    color: var(--ac-fg);
    background: var(--ac-hi);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Workout Overview */
.workout-overview {
    margin-bottom: 10px;
}

.overview-card {
    background: var(--bg);
    border-radius: 0;
    padding: 16px 20px;
    border: 1px solid var(--bd);
}

.overview-card h2 {
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--c2);
    margin-bottom: 12px;
    text-align: left;
}

.workout-stats {
    display: flex;
    justify-content: space-between;
    gap: 20px;
}

.stat {
    text-align: left;
}

.stat-value {
    display: block;
    font-family: var(--lcd-font);
    font-size: 34px;
    line-height: 1;
    font-weight: 400;
    color: var(--ac);
    text-shadow: 0 0 12px rgba(94, 242, 160, 0.45);
}

.stat-label {
    font-size: 9px;
    color: var(--c2);
    text-transform: uppercase;
    letter-spacing: 0.22em;
}

/* Timer Section — the LCD deck */
.timer-section {
    text-align: center;
    margin-bottom: 20px;
    border: 1px solid var(--bd);
    background: var(--lcd);
    padding: 22px 16px 20px;
    position: relative;
    overflow: hidden;
}

.timer-section::before {
    content: "";
    pointer-events: none;
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(180deg, rgba(0, 0, 0, 0.42) 0 2px, transparent 2px 4px);
    opacity: 0.5;
}

.timer-display {
    position: relative;
    display: inline-block;
    margin-bottom: 20px;
}

.timer-circle {
    position: relative;
    width: 220px;
    height: 220px;
    margin: 0 auto;
    transform: translateZ(0);
    will-change: transform;
}

.timer-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.timer-background {
    fill: none;
    stroke: var(--trk);
    stroke-width: 8;
}

.timer-progress {
    fill: none;
    stroke: var(--ac);
    stroke-width: 8;
    stroke-linecap: butt;
    transition: stroke-dashoffset 0.3s ease;
    transform: translateZ(0);
    will-change: stroke-dashoffset;
    filter: drop-shadow(0 0 8px rgba(94, 242, 160, 0.8));
}

.timer-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--lcd-font);
    font-size: 56px;
    line-height: 1;
    font-weight: 400;
    color: var(--ac);
    text-shadow: 0 0 16px rgba(94, 242, 160, 0.55);
}

.timer-controls {
    position: relative;
    display: flex;
    justify-content: center;
    gap: 0;
    flex-wrap: wrap;
    border: 1px solid var(--bd);
    width: fit-content;
    margin: 0 auto;
    background: var(--bg);
}

.control-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 0;
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
    min-width: 100px;
    background: transparent;
    color: var(--fg);
}

.control-btn + .control-btn {
    border-left: 1px solid var(--bd);
}

.control-btn.primary {
    background: var(--ac);
    color: var(--ac-fg);
    box-shadow: none;
}

.control-btn.secondary {
    background: transparent;
    color: var(--fg);
    border-top: none;
    border-right: none;
    border-bottom: none;
}

.control-btn:hover {
    transform: none;
    box-shadow: none;
}

.control-btn.primary:hover {
    background: var(--ac-hi);
    color: var(--ac-fg);
}

.control-btn.secondary:hover {
    color: var(--ac);
    background: var(--row-hov);
}

/* Current Exercise */
.current-exercise {
    margin-bottom: 20px;
}

.exercise-card {
    background: var(--bg);
    border-radius: 0;
    padding: 20px;
    border: 1px solid var(--bd);
    text-align: left;
}

.exercise-card h3 {
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0.1em;
    margin-bottom: 8px;
    color: var(--ac);
    text-shadow: none;
    letter-spacing: 0.06em;
}

.exercise-card h3::before {
    content: "* ";
    color: var(--g1);
}

.exercise-card p {
    font-size: 12px;
    color: var(--c2);
    margin-bottom: 15px;
    line-height: 1.7;
}

.biohack-tip {
    background: var(--lcd);
    border-radius: 0;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--bd);
    border-left: 2px solid var(--ac);
}

.tip-icon {
    font-size: 16px;
    filter: grayscale(1) brightness(1.6) sepia(1) hue-rotate(85deg) saturate(3);
}

.biohack-tip span:last-child {
    font-size: 12px;
    color: var(--fg);
    line-height: 1.6;
}

/* Progress Section — blocky meter */
.progress-section {
    margin-bottom: 20px;
}

.progress-bar {
    width: 100%;
    height: 10px;
    background: var(--trk);
    border: 1px solid var(--bd);
    border-radius: 0;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: repeating-linear-gradient(
        90deg,
        var(--ac) 0 6px,
        transparent 6px 9px
    );
    border-radius: 0;
    transition: width 0.3s ease;
    width: 0%;
    box-shadow: 0 0 10px rgba(94, 242, 160, 0.4);
}

.progress-text {
    display: flex;
    justify-content: space-between;
    font-size: 9px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--c2);
}

/* Phases Section — playlist deck */
.phases-section {
    margin-bottom: 20px;
}

.phase-tabs {
    display: flex;
    background: transparent;
    border: 1px solid var(--bd);
    border-radius: 0;
    padding: 0;
    margin-bottom: 0;
    border-bottom: none;
}

.phase-tab {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    color: var(--c2);
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    cursor: pointer;
    border-radius: 0;
    transition: background 0.2s ease, color 0.2s ease;
}

.phase-tab + .phase-tab {
    border-left: 1px solid var(--bd);
}

.phase-tab.active {
    background: var(--ac);
    color: var(--ac-fg);
}

.phase-content {
    background: var(--bg);
    border-radius: 0;
    padding: 6px 0;
    border: 1px solid var(--bd);
    max-height: 300px;
    overflow-y: auto;
    transform: translateZ(0);
    will-change: scroll-position;
    counter-reset: exercise;
}

.exercise-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--bd-f);
    position: relative;
    counter-increment: exercise;
}

.exercise-item:last-child {
    border-bottom: none;
}

.exercise-item.completed {
    opacity: 0.45;
}

.exercise-item.completed .exercise-details h4 {
    text-decoration: line-through;
    text-decoration-color: var(--g1);
}

.exercise-item.current {
    background: var(--row-on);
    border-radius: 0;
    padding: 12px 16px;
    margin: 0;
    border-left: 2px solid var(--ac);
    border-bottom: 1px solid var(--bd-f);
    animation: rowblink 2s step-end infinite;
}

.exercise-item.current .exercise-icon {
    background: transparent;
    border-color: var(--ac);
    animation: none;
}

.exercise-icon {
    width: 34px;
    height: 34px;
    background: transparent;
    border: 1px solid var(--bd);
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex: none;
    filter: grayscale(1) brightness(1.6) sepia(1) hue-rotate(85deg) saturate(2.5);
}

.exercise-details {
    flex: 1;
    min-width: 0;
}

.exercise-details h4 {
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--fg);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.exercise-details h4::before {
    content: counter(exercise, decimal-leading-zero) "  ";
    font-family: var(--lcd-font);
    font-size: 16px;
    color: var(--c2);
}

.exercise-item.current .exercise-details h4 {
    color: var(--ac);
}

.exercise-item.current .exercise-details h4::before {
    color: var(--ac);
}

.exercise-details p {
    font-size: 10px;
    letter-spacing: 0.06em;
    color: var(--c2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.exercise-meta {
    margin-left: auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    flex: none;
}

.exercise-time {
    font-family: var(--lcd-font);
    font-size: 17px;
    line-height: 1;
    color: var(--ac);
    font-weight: 400;
}

.video-btn {
    background: transparent;
    border: 1px solid var(--bd);
    color: var(--c2);
    padding: 6px 12px;
    border-radius: 0;
    font-family: var(--mono);
    font-size: 9px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease;
    white-space: nowrap;
}

.video-btn:hover {
    background: transparent;
    color: var(--ac);
    border-color: var(--ac);
    transform: none;
    box-shadow: none;
}

/* Video Notification */
.video-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    animation: slideInRight 0.3s ease;
}

/* Visual Notification */
.visual-notification {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    animation: fadeInOut 2s ease;
}

.notification-content {
    background: var(--lcd);
    color: var(--ac);
    border: 1px solid var(--ac);
    padding: 12px 20px;
    border-radius: 0;
    box-shadow: 0 0 24px rgba(94, 242, 160, 0.25);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeInOut {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    20% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    80% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
}

/* Responsive Design */
@media (max-width: 480px) {
    .app-container {
        max-width: 100%;
        border-left: none;
        border-right: none;
    }

    .header {
        padding: 15px;
    }

    .header h1 {
        font-size: 12px;
    }

    .main-content {
        padding: 15px;
    }

    .timer-circle {
        width: 150px;
        height: 150px;
    }

    .timer-text {
        font-size: 40px;
    }

    .control-btn {
        padding: 10px 16px;
        font-size: 10px;
        min-width: 80px;
    }

    .workout-stats {
        gap: 15px;
    }

    .stat-value {
        font-size: 28px;
    }
}

/* Wide-screen layout (tablet landscape, laptop, desktop) */
@media (min-width: 600px) {
    .app-container {
        max-width: 640px;
    }

    .settings-row {
        flex-direction: row;
        justify-content: center;
        gap: 16px;
    }

    .timer-circle {
        width: 240px;
        height: 240px;
    }

    .timer-text {
        font-size: 62px;
    }
}

@media (min-width: 900px) {
    .app-container {
        max-width: 1080px;
    }

    .header h1 {
        font-size: 17px;
    }

    .main-content {
        display: grid;
        grid-template-columns: minmax(300px, 5fr) 7fr;
        grid-template-areas:
            "overview overview"
            "timer phases"
            "exercise phases"
            "progress phases";
        gap: 24px;
        align-items: start;
    }

    .workout-overview {
        grid-area: overview;
        margin-bottom: 0;
    }

    .timer-section {
        grid-area: timer;
        margin-bottom: 0;
    }

    .current-exercise {
        grid-area: exercise;
        margin-bottom: 0;
    }

    .progress-section {
        grid-area: progress;
        margin-bottom: 0;
    }

    .phases-section {
        grid-area: phases;
        margin-bottom: 0;
    }

    .timer-circle {
        width: 260px;
        height: 260px;
    }

    .timer-text {
        font-size: 68px;
    }

    .phase-content {
        max-height: 560px;
    }
}

@media (min-width: 1300px) {
    .app-container {
        max-width: 1200px;
    }

    .phase-content {
        max-height: 620px;
    }
}

/* Animations */
@keyframes pulse {
    0% { filter: drop-shadow(0 0 4px rgba(94, 242, 160, 0.4)); }
    50% { filter: drop-shadow(0 0 14px rgba(94, 242, 160, 0.9)); }
    100% { filter: drop-shadow(0 0 4px rgba(94, 242, 160, 0.4)); }
}

@keyframes blink {
    0%, 55% { opacity: 1; }
    56%, 100% { opacity: 0.12; }
}

@keyframes rowblink {
    0%, 55% { background-color: var(--row-on); }
    56%, 100% { background-color: rgba(20, 39, 28, 0.45); }
}

.timer-circle.active {
    animation: pulse 2s infinite;
    transform: translateZ(0);
}

/* Scrollbar Styling */
.phase-content::-webkit-scrollbar {
    width: 8px;
}

.phase-content::-webkit-scrollbar-track {
    background: var(--lcd);
    border-radius: 0;
}

.phase-content::-webkit-scrollbar-thumb {
    background: var(--bd);
    border-radius: 0;
}

.phase-content::-webkit-scrollbar-thumb:hover {
    background: var(--g1);
}

/* Loading States */
.loading {
    opacity: 0.7;
    pointer-events: none;
}

/* Success States */
.success {
    background: var(--ac) !important;
    color: var(--ac-fg) !important;
}

/* Error States */
.error {
    background: #3a1215 !important;
    color: #ff7b72 !important;
    border-color: #3a1215 !important;
}

/* Wake Lock Notifications */
.wake-lock-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    animation: slideInDown 0.3s ease;
    background: var(--lcd);
    border: 1px solid var(--bd);
    color: var(--fg);
    padding: 10px 16px;
    font-size: 10px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

.wake-lock-notification.info {
    background: var(--lcd);
    border-color: var(--bd);
}

.wake-lock-notification.success {
    background: var(--lcd);
    border-color: var(--ac);
    color: var(--ac);
}

.wake-lock-notification.warning {
    background: var(--lcd);
    border-color: #8a6d1c;
    color: #e3b341;
}

.wake-lock-notification.error {
    background: var(--lcd);
    border-color: #5c1a1a;
    color: #ff7b72;
}

@keyframes slideInDown {
    from {
        transform: translateX(-50%) translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

/* Tip jar footer */
.tip-jar {
    border-top: 1px solid var(--bd);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px 14px;
    font-size: 9px;
    font-weight: 500;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--c2);
}

.tip-link {
    color: var(--ac);
    text-decoration: none;
    border-bottom: 1px solid var(--bd);
}

.tip-link:hover {
    color: var(--fg);
    border-color: var(--ac);
}

.tip-sep {
    color: var(--c3);
}

.tip-static {
    color: var(--c2);
}

@media (prefers-reduced-motion: reduce) {
    .timer-circle.active,
    .header h1::after,
    .exercise-item.current {
        animation: none;
    }
}
