/*
 * ESL Timecard - phone first.
 *
 * The whole app is one thumb on a phone held in one hand, outdoors, often in
 * sun. So: one column, large type, a primary button that cannot be missed or
 * mis-tapped, and colour that carries meaning only alongside a word, because
 * the punch list is read at a glance and sometimes through a cracked screen.
 */

:root {
    --navy: #1b2a4a;
    --navy-dark: #0f1a30;
    --accent: #2563eb;
    --accent-press: #1d4ed8;
    --success: #15803d;
    --success-soft: #dcfce7;
    --warning: #b45309;
    --warning-soft: #fef3c7;
    --danger: #b91c1c;
    --danger-soft: #fee2e2;
    --ink: #111827;
    --ink-soft: #4b5563;
    --line: #d1d5db;
    --surface: #ffffff;
    --page: #f3f4f6;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.06);
}

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

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
    font-size: 17px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--page);
    min-height: 100vh;
}

body.centered {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem;
}

/* ---------------------------------------------------------------- topbar */

.topbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    padding-top: calc(0.75rem + env(safe-area-inset-top));
    background: var(--navy);
    color: #ffffff;
}

.topbar-brand {
    font-weight: 700;
    font-size: 1rem;
}

.topbar-link {
    color: inherit;
    font-size: 0.85rem;
    text-decoration: underline;
}

.topbar-user {
    margin-left: auto;
    font-size: 0.9rem;
    opacity: 0.85;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-signout button {
    background: none;
    border: 1px solid currentColor;
    border-radius: 6px;
    color: inherit;
    font: inherit;
    font-size: 0.85rem;
    padding: 0.25rem 0.6rem;
    cursor: pointer;
}

/* ---------------------------------------------------------------- layout */

.screen {
    width: 100%;
    max-width: 30rem;
    margin: 0 auto;
    padding: 1rem;
    padding-bottom: calc(2rem + env(safe-area-inset-bottom));
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.card-title {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
}

.card-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
    max-width: 22rem;
    margin-bottom: 0;
}

.card-form label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ink-soft);
    margin-top: 0.5rem;
}

/* 17px minimum: iOS Safari zooms the whole page when a focused input is
   smaller than this, and the page never zooms back out. */
.card-form input {
    font: inherit;
    font-size: 17px;
    padding: 0.7rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
}

.card-form input:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 1px;
}

.form-error {
    background: var(--danger-soft);
    border-left: 4px solid var(--danger);
    color: #7f1d1d;
    padding: 0.6rem 0.75rem;
    border-radius: 6px;
    font-size: 0.95rem;
}

.form-note {
    font-size: 0.9rem;
    color: var(--ink-soft);
}

/* ---------------------------------------------------------------- buttons */

.button-primary {
    font: inherit;
    font-weight: 700;
    color: #ffffff;
    background: var(--accent);
    border: none;
    border-radius: 10px;
    padding: 0.85rem 1rem;
    margin-top: 1rem;
    cursor: pointer;
    min-height: 3rem;
}

.button-primary:active {
    background: var(--accent-press);
}

.button-primary:disabled {
    opacity: 0.55;
    cursor: default;
}

.button-secondary {
    font: inherit;
    color: var(--accent);
    background: var(--surface);
    border: 1px solid var(--accent);
    border-radius: 10px;
    padding: 0.7rem 1rem;
    cursor: pointer;
    min-height: 2.75rem;
}

/* The one button the whole app exists for. Deliberately enormous: it is
   pressed with a thumb, sometimes with gloves on, sometimes in a hurry. */
.punch-button {
    display: block;
    width: 100%;
    font: inherit;
    font-size: 1.35rem;
    font-weight: 700;
    color: #ffffff;
    background: var(--accent);
    border: none;
    border-radius: var(--radius);
    padding: 1.5rem 1rem;
    min-height: 5.5rem;
    cursor: pointer;
    box-shadow: var(--shadow);
}

.punch-button:active {
    background: var(--accent-press);
}

.punch-button:disabled {
    opacity: 0.55;
    cursor: default;
}

.punch-button[data-kind="clock_out"] {
    background: var(--navy);
}

.punch-button[data-kind="clock_out"]:active {
    background: var(--navy-dark);
}

/* ---------------------------------------------------------------- status */

.status-card {
    text-align: center;
}

.status-state {
    font-size: 1.5rem;
    font-weight: 700;
}

.status-since {
    color: var(--ink-soft);
    font-size: 0.95rem;
}

.status-worked {
    margin-top: 0.5rem;
    font-size: 1rem;
    color: var(--ink-soft);
}

.status-card[data-state="clocked_in"] .status-state {
    color: var(--success);
}

.status-card[data-state="on_break"] .status-state {
    color: var(--warning);
}

/* ---------------------------------------------------------------- banner */

.banner {
    display: none;
    border-radius: var(--radius);
    padding: 0.9rem 1rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

.banner[data-visible="true"] {
    display: block;
}

.banner[data-severity="rest"] {
    background: var(--success-soft);
    border-left: 4px solid var(--success);
    color: #14532d;
}

.banner[data-severity="soon"] {
    background: var(--warning-soft);
    border-left: 4px solid var(--warning);
    color: #78350f;
}

.banner[data-severity="overdue"] {
    background: var(--danger-soft);
    border-left: 4px solid var(--danger);
    color: #7f1d1d;
}

.banner-countdown {
    display: block;
    font-variant-numeric: tabular-nums;
    font-size: 1.1rem;
    margin-top: 0.2rem;
}

.banner-countdown:empty {
    display: none;
}

/* ---------------------------------------------------------------- punches */

.punch-list {
    list-style: none;
}

.punch-row {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--line);
}

.punch-row:last-child {
    border-bottom: none;
}

.punch-time {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    min-width: 5.5rem;
}

.punch-kind {
    flex: 1;
}

.punch-flag {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    background: var(--warning-soft);
    color: #78350f;
}

.punch-flag[data-status="inside"] {
    display: none;
}

.punch-empty {
    color: var(--ink-soft);
}

/* ---------------------------------------------------------------- waiver */

.waiver-box {
    display: none;
}

.waiver-box[data-visible="true"] {
    display: block;
}

.waiver-text {
    font-size: 0.92rem;
    color: var(--ink-soft);
    margin-bottom: 0.75rem;
}

/* ---------------------------------------------------------------- errors */

.punch-error {
    display: none;
    background: var(--danger-soft);
    border-left: 4px solid var(--danger);
    color: #7f1d1d;
    padding: 0.7rem 0.85rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.punch-error[data-visible="true"] {
    display: block;
}

.noscript-note {
    background: var(--warning-soft);
    border-left: 4px solid var(--warning);
    color: #78350f;
    padding: 0.7rem 0.85rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

/* ---------------------------------------------------------------- dark */

@media (prefers-color-scheme: dark) {
    :root {
        --ink: #f3f4f6;
        --ink-soft: #9ca3af;
        --line: #374151;
        --surface: #111827;
        --page: #030712;
        --success-soft: #052e16;
        --warning-soft: #422006;
        --danger-soft: #450a0a;
    }

    .form-error,
    .punch-error {
        color: #fecaca;
    }

    .banner[data-severity="rest"] {
        color: #bbf7d0;
    }

    .banner[data-severity="soon"],
    .punch-flag {
        color: #fde68a;
    }

    .banner[data-severity="overdue"] {
        color: #fecaca;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
}
