/* ============================================================
   Focus.Axo — Styles
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;700;800&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Root / Body ─────────────────────────────────────────── */
:root {
    --green:   #34d399;
    --green-d: #059669;
    --red:     #ef4444;
    --bg:      #0a0a0b;
    --bg2:     #111113;
    --bg3:     #18181b;
    --border:  #27272a;
    --z3:      #3f3f46;
    --z4:      #52525b;
    --z5:      #71717a;
    --z6:      #a1a1aa;
    --z2:      #d4d4d8;
    --z1:      #f4f4f5;
    --font:    'JetBrains Mono', 'Fira Code', monospace;
}

.focus-body {
    font-family: var(--font);
    background-color: var(--bg);
    color: var(--z2);
    min-height: 100dvh;
    display: grid;
    grid-template-rows: auto 1fr auto auto;
    grid-template-areas:
        "header"
        "main"
        "player"
        "footer";
    overflow: hidden;
    user-select: none;
}

/* Atmospheric bg glow */
.focus-body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 60% 40% at 15% 60%, rgba(52, 211, 153, 0.04) 0%, transparent 70%),
        radial-gradient(ellipse 50% 30% at 85% 40%, rgba(99, 102, 241, 0.03) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* ── Header ──────────────────────────────────────────────── */
.focus-header {
    grid-area: header;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 2rem;
    border-bottom: 1px solid var(--border);
    position: relative;
    z-index: 10;
}

.header-brand { display: flex; flex-direction: column; gap: 2px; }

.brand-logo {
    font-size: 1.375rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--z1);
}

.brand-logo .dot { color: var(--green); }

.brand-sub {
    font-size: 0.625rem;
    letter-spacing: 0.22em;
    color: var(--z4);
    font-weight: 400;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-avatar {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border);
}

.user-name {
    font-size: 0.8125rem;
    color: var(--z6);
}

.btn-login, .btn-logout {
    font-size: 0.75rem;
    color: var(--z5);
    text-decoration: none;
    border: 1px solid var(--border);
    padding: 0.3rem 0.75rem;
    border-radius: 0.375rem;
    letter-spacing: 0.05em;
    transition: color 0.2s, border-color 0.2s;
}

.btn-login:hover { color: var(--z2); border-color: var(--z4); }
.btn-logout:hover { color: var(--red); border-color: var(--red); }

.btn-lang {
    font-size: 0.7rem;
    font-family: inherit;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--z5);
    background: none;
    border: 1px solid var(--border);
    padding: 0.3rem 0.6rem;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}
.btn-lang:hover { color: var(--green); border-color: var(--green); }

.stats-block {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.stat-label {
    font-size: 0.55rem;
    letter-spacing: 0.2em;
    color: var(--z4);
}

.stat-val {
    font-size: 1.375rem;
    font-weight: 800;
    line-height: 1;
}

.stat-val.success { color: var(--green); }
.stat-val.failed  { color: var(--red); }

.stat-divider {
    width: 1px;
    height: 2rem;
    background: var(--border);
}

/* ── Main ────────────────────────────────────────────────── */
.focus-main {
    grid-area: main;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2.5rem;
    position: relative;
    z-index: 1;
    padding: 1rem;
}

/* ── Mode Tabs ───────────────────────────────────────────── */
.mode-tabs {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    flex-wrap: wrap;
    justify-content: center;
}

.tab-btn {
    padding: 0.45rem 1.1rem;
    border-radius: 2rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--z5);
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    font-family: var(--font);
    transition: color 0.2s, background 0.2s, border-color 0.2s;
    position: relative;
}

.tab-btn:hover { color: var(--z3); }

.tab-btn.active {
    background-color: var(--green-d);
    color: #fff;
    border-color: transparent;
}

.tab-btn.custom {
    border-color: var(--border);
    padding-right: 0.6rem;
}

.tab-btn.custom.active { border-color: transparent; }

.tab-del {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.1rem;
    height: 1.1rem;
    border-radius: 50%;
    font-size: 0.875rem;
    margin-left: 0.25rem;
    color: rgba(255,255,255,0.5);
    vertical-align: middle;
    transition: color 0.15s, background 0.15s;
}

.tab-del:hover {
    color: var(--red);
    background: rgba(239, 68, 68, 0.15);
}

.tab-add {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    border: 1px dashed var(--z3);
    color: var(--z4);
    background: transparent;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    font-family: var(--font);
    transition: color 0.2s, border-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tab-add:hover { color: var(--green); border-color: var(--green); }

/* ── Timer ───────────────────────────────────────────────── */
.timer-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    width: 100%;
}

.timer-digits {
    display: flex;
    align-items: center;
    gap: 0;
    line-height: 1;
    transition: color 0.5s ease;
}

.digit-group {
    font-size: clamp(6rem, 23vw, 14rem);
    font-weight: 800;
    letter-spacing: -0.04em;
    color: var(--z3);
    transition: color 0.5s ease, text-shadow 0.5s ease;
    font-variant-numeric: tabular-nums;
    min-width: 2ch;
    text-align: center;
}

.digit-colon {
    font-size: clamp(5rem, 18vw, 11rem);
    font-weight: 800;
    color: var(--z3);
    margin: 0 0.05em;
    padding-bottom: 0.1em;
    transition: color 0.5s ease;
    animation: colonBlink 2s step-start infinite;
}

@keyframes colonBlink {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0.2; }
}

/* Running state */
.timer-digits.running .digit-group,
.timer-digits.running .digit-colon {
    color: var(--green);
    text-shadow: 0 0 120px rgba(52, 211, 153, 0.2), 0 0 40px rgba(52, 211, 153, 0.1);
}

/* Rest mode */
.timer-digits.rest-mode.running .digit-group,
.timer-digits.rest-mode.running .digit-colon {
    color: #818cf8;
    text-shadow: 0 0 120px rgba(129, 140, 248, 0.2), 0 0 40px rgba(129, 140, 248, 0.1);
}

/* Progress bar */
.timer-progress {
    width: min(480px, 80vw);
    height: 2px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.timer-progress-fill {
    height: 100%;
    width: 100%;
    background: var(--green);
    border-radius: 2px;
    transition: width 1s linear;
    transform-origin: left;
}

.timer-progress-fill.rest-fill { background: #818cf8; }

/* Session counter */
.session-counter {
    font-size: 0.75rem;
    color: var(--z4);
    letter-spacing: 0.2em;
}

/* ── Controls ────────────────────────────────────────────── */
.controls {
    display: flex;
    align-items: center;
    gap: 0.875rem;
}

.btn-start {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.9rem 2.5rem;
    background: var(--green-d);
    color: #fff;
    border: none;
    border-radius: 0.875rem;
    font-size: 0.9375rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    cursor: pointer;
    font-family: var(--font);
    min-width: 220px;
    justify-content: center;
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
}

.btn-start:hover {
    background: #10b981;
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(16, 185, 129, 0.3);
}

.btn-start:active { transform: translateY(0); }

.btn-start.running {
    background: var(--bg3);
    color: var(--z5);
    box-shadow: none;
    border: 1px solid var(--border);
}

.btn-start.running:hover {
    background: var(--z3);
    color: var(--z2);
    transform: translateY(-1px);
    box-shadow: none;
}

.btn-icon {
    width: 1.1rem;
    height: 1.1rem;
}

.btn-reset {
    width: 3rem;
    height: 3rem;
    border-radius: 0.75rem;
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--z5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.btn-reset svg { width: 1.25rem; height: 1.25rem; }
.btn-reset:hover { color: var(--z2); border-color: var(--z4); }

/* ── Bottom Player Bar ───────────────────────────────────── */
.player-bar {
    grid-area: player;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0.875rem 2rem;
    border-top: 1px solid var(--border);
    background: var(--bg2);
    position: relative;
    z-index: 10;
}

.player-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 160px;
}

.player-label {
    font-size: 0.6rem;
    letter-spacing: 0.2em;
    color: var(--z4);
}

.player-track {
    font-size: 0.8125rem;
    color: var(--z6);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.player-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.player-btn {
    width: 2.125rem;
    height: 2.125rem;
    border-radius: 50%;
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--z6);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background 0.2s, border-color 0.2s;
    flex-shrink: 0;
}

.player-btn svg { width: 1rem; height: 1rem; }

.player-btn:hover { color: var(--z1); border-color: var(--z4); }

.player-btn.playing {
    background: var(--green-d);
    border-color: transparent;
    color: #fff;
}

.player-volume {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    max-width: 200px;
}

.vol-icon { width: 0.875rem; height: 0.875rem; color: var(--z4); flex-shrink: 0; }

.vol-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 3px;
    border-radius: 2px;
    background: var(--border);
    outline: none;
    cursor: pointer;
}

.vol-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--z4);
    cursor: pointer;
    transition: background 0.2s;
}

.vol-slider::-webkit-slider-thumb:hover { background: var(--z6); }
.vol-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--z4);
    border: none;
    cursor: pointer;
}

.stream-dots {
    display: flex;
    gap: 0.375rem;
    align-items: center;
}

.stream-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--z3);
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
}

.stream-dot:hover { transform: scale(1.4); }
.stream-dot.active { background: var(--green); transform: scale(1.3); }

.btn-fullscreen {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.6875rem;
    letter-spacing: 0.1em;
    color: var(--z5);
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: var(--font);
    transition: color 0.2s;
    margin-left: auto;
    white-space: nowrap;
}

.btn-fullscreen svg { width: 0.875rem; height: 0.875rem; }
.btn-fullscreen:hover { color: var(--z2); }

/* ── Footer ──────────────────────────────────────────────── */
.focus-footer {
    grid-area: footer;
    text-align: center;
    padding: 0.625rem;
    font-size: 0.6875rem;
    color: var(--z4);
    letter-spacing: 0.05em;
}

.focus-footer a { color: var(--z5); text-decoration: none; transition: color 0.2s; }
.focus-footer a:hover { color: var(--z2); }

/* ── Fail Overlay ────────────────────────────────────────── */
.fail-overlay {
    position: fixed;
    inset: 0;
    background: #030000;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    animation: failFlash 0.6s ease-out forwards;
}

.fail-overlay.hidden { display: none; }

@keyframes failFlash {
    0%   { background: #dc2626; }
    20%  { background: #7f1d1d; }
    60%  { background: #0d0000; }
    100% { background: #030000; }
}

.fail-scanlines {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent, transparent 2px,
        rgba(0,0,0,0.25) 2px, rgba(0,0,0,0.25) 4px
    );
    pointer-events: none;
    opacity: 0.5;
}

.fail-box {
    position: relative;
    z-index: 1;
    text-align: center;
    animation: failIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes failIn {
    from { transform: scale(0.8) translateY(16px); opacity: 0; }
    to   { transform: scale(1) translateY(0);       opacity: 1; }
}

.fail-x {
    font-size: 5rem;
    font-weight: 900;
    color: var(--red);
    line-height: 1;
    margin-bottom: 1.5rem;
    animation: failPulse 1.1s ease-in-out infinite;
}

@keyframes failPulse {
    0%, 100% { text-shadow: 0 0 60px rgba(239,68,68,0.9), 0 0 120px rgba(239,68,68,0.4); }
    50%       { text-shadow: 0 0 10px rgba(239,68,68,0.2); opacity: 0.5; }
}

.fail-title {
    font-size: clamp(1.75rem, 5vw, 2.875rem);
    font-weight: 900;
    color: #fef2f2;
    letter-spacing: 0.12em;
    font-family: var(--font);
    margin-bottom: 0.625rem;
}

.fail-reason {
    font-size: 0.9375rem;
    color: var(--red);
    letter-spacing: 0.22em;
    font-weight: 700;
    margin-bottom: 0.375rem;
}

.fail-time {
    font-size: 0.75rem;
    color: #7f1d1d;
    letter-spacing: 0.15em;
    margin-bottom: 3rem;
}

.fail-retry {
    padding: 0.875rem 2rem;
    background: #0a0000;
    border: 1px solid var(--z3);
    color: var(--z5);
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    border-radius: 0.625rem;
    cursor: pointer;
    font-family: var(--font);
    transition: all 0.2s;
}

.fail-retry:hover { background: var(--bg3); color: var(--z2); border-color: var(--z5); }

/* ── Add Timer Modal ─────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(4px);
}

.modal-overlay.hidden { display: none; }

.modal-box {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 2rem;
    width: 100%;
    max-width: 360px;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.modal-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--z1);
    letter-spacing: 0.05em;
}

.modal-field {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.modal-field label {
    font-size: 0.6875rem;
    color: var(--z5);
    letter-spacing: 0.12em;
}

.modal-field input {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.625rem 0.875rem;
    color: var(--z1);
    font-size: 0.9375rem;
    font-family: var(--font);
    outline: none;
    transition: border-color 0.2s;
}

.modal-field input:focus { border-color: var(--green); }

.modal-field-row {
    flex-direction: row;
    gap: 0.75rem;
}

.modal-field-row > div {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.modal-cancel {
    padding: 0.625rem 1.25rem;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--z5);
    border-radius: 0.5rem;
    font-family: var(--font);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-cancel:hover { color: var(--z2); border-color: var(--z4); }

.modal-save {
    padding: 0.625rem 1.5rem;
    background: var(--green-d);
    border: none;
    color: #fff;
    border-radius: 0.5rem;
    font-family: var(--font);
    font-size: 0.8125rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
}

.modal-save:hover { background: #10b981; }

/* ── Utility ──────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 600px) {
    .focus-header { padding: 1rem; }
    .header-right { gap: 0.75rem; }
    .stats-block { gap: 0.625rem; }
    .brand-sub { display: none; }
    .player-bar { flex-wrap: wrap; gap: 0.75rem; padding: 0.75rem 1rem; }
    .player-left { min-width: unset; }
    .btn-fullscreen { display: none; }
    .player-volume { max-width: 130px; }
}
