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

:root {
    --bg: #050506;
    --surface: #111827;
    --surface-light: #1f2937;
    --accent: #FFB703;
    --accent-glow: rgba(255, 183, 3, 0.35);
    --accent-soft: rgba(255, 183, 3, 0.15);
    --text: #ffffff;
    --text-dim: #9ca3af;
    --danger: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.4);
    --radius: 16px;
    --radius-sm: 12px;
}

html,
body {
    min-height: 100vh;
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-tap-highlight-color: transparent;
}

/* ─── Layout ─── */
.app {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    max-width: 480px;
    margin: 0 auto;
    padding: 0 1.2rem;
}

/* ─── Header ─── */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.2rem 0 0.6rem;
    flex-shrink: 0;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent), #e85d04);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.icon-btn {
    font-size: 1.4rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 8px;
    transition: background 0.2s;
    color: var(--text);
}

.icon-btn:hover {
    background: var(--surface-light);
}

/* ─── Main ─── */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    padding: 1rem 0;
    align-items: center;
}

/* ─── Timer Ring & Display ─── */
.timer-container {
    position: relative;
    width: 280px;
    height: 280px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: scaleIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}

.timer-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
    /* Start at 12 o'clock */
    filter: drop-shadow(0 0 15px rgba(0, 0, 0, 0.5));
}

.timer-bg {
    fill: none;
    stroke: var(--surface);
    stroke-width: 4;
}

.timer-progress {
    fill: none;
    stroke: var(--accent);
    stroke-width: 6;
    stroke-linecap: round;
    /* Circumference = 2 * PI * r = 2 * PI * 45 = 282.74 */
    stroke-dasharray: 283;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 0.1s linear, stroke 0.3s;
}

/* When time is up */
.timer-progress.danger {
    stroke: var(--danger);
    filter: drop-shadow(0 0 10px var(--danger-glow));
}

/* ─── Time Input ─── */
.timer-display {
    position: relative;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.time-input {
    width: 80px;
    background: transparent;
    border: none;
    color: var(--text);
    font-family: 'Roboto Mono', monospace;
    font-size: 4.5rem;
    font-weight: 700;
    text-align: center;
    padding: 0;
    outline: none;
    transition: color 0.3s;
}

/* Hide arrows for number inputs */
.time-input::-webkit-outer-spin-button,
.time-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.time-input[type=number] {
    -moz-appearance: textfield;
    appearance: textfield;
}

.time-input:focus {
    color: var(--accent);
}

.time-colon {
    font-family: 'Roboto Mono', monospace;
    font-size: 4rem;
    font-weight: 700;
    color: var(--text-dim);
    margin: 0 -5px;
    padding-bottom: 8px;
    /* Alignment tweak */
}

/* Ringing Animation */
.timer-container.ringing {
    animation: shake 0.5s ease-in-out infinite;
}

.timer-container.ringing .time-input,
.timer-container.ringing .time-colon {
    color: var(--danger);
}

/* ─── Controls ─── */
.controls {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    animation: fadeIn 0.4s ease-out 0.2s backwards;
}

.ctl-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s, opacity 0.2s;
}

.ctl-btn:active:not(:disabled) {
    transform: scale(0.92);
}

.ctl-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

.ctl-btn.primary {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--accent), #e85d04);
    color: #fff;
    box-shadow: 0 8px 24px var(--accent-glow);
}

.ctl-btn.primary:hover:not(:disabled) {
    box-shadow: 0 12px 30px var(--accent-glow);
    transform: translateY(-2px);
}

.ctl-btn.primary.pause-state {
    background: linear-gradient(135deg, #f43f5e, #be123c);
    box-shadow: 0 8px 24px rgba(244, 63, 94, 0.3);
}

.ctl-btn.secondary {
    width: 56px;
    height: 56px;
    background: var(--surface);
    color: var(--text-dim);
    border: 2px solid rgba(255, 255, 255, 0.08);
}

.ctl-btn.secondary:hover:not(:disabled) {
    background: var(--surface-light);
    color: var(--text);
    border-color: rgba(255, 255, 255, 0.2);
}

/* ─── Presets ─── */
.presets-section {
    width: 100%;
    margin-top: auto;
    animation: fadeIn 0.4s ease-out 0.3s backwards;
    text-align: center;
}

.presets-section h3 {
    font-size: 0.85rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.8rem;
    font-weight: 600;
}

.presets {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
}

.preset-btn {
    padding: 0.8rem 0;
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.preset-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--surface-light);
}

/* ─── Footer ─── */
footer {
    flex-shrink: 0;
    padding: 1.5rem 0 1rem;
    margin-top: 1rem;
}

.app-footer {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-dim);
    line-height: 1.5;
}

.app-footer a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

/* ─── Animations ─── */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.85);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-4px) rotate(-1deg);
    }

    75% {
        transform: translateX(4px) rotate(1deg);
    }
}