/* === Braun Calculator — 极简考勤打卡 === */

/* DM Mono loaded locally if available, otherwise falls back to system monospace.
   Google Fonts is blocked in China, so we ship with system font stack that
   renders well on both iOS (SF Mono) and Android (Roboto Mono via ui-monospace). */

/* ===== Token System (auto-generated, do not edit) ===== */
/* Source: design/tokens/tokens.json → node design/tokens/build.js → static/tokens.css */
/* If tokens.css is missing, fall back to inline token definitions */
@import 'tokens.css';

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

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

body {
    font-family: var(--font-body);
    background: var(--paper);
    color: var(--ink);
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
    letter-spacing: -0.01em;
}

/* === Container === */
.app-container {
    max-width: 420px;
    margin: 0 auto;
    min-height: 100dvh;
    padding: calc(var(--grid) * 3) calc(var(--grid) * 2);
    display: flex;
    flex-direction: column;
}

/* === Top Nav — text links only === */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: calc(var(--grid) * 6);
}

.nav-left, .nav-right {
    display: flex;
    gap: calc(var(--grid) * 2);
}

.nav-link {
    font-size: 0.8125rem;
    color: var(--muted);
    text-decoration: none;
    letter-spacing: 0.02em;
    transition: color 0.2s;
    padding: 4px 0;
}

.nav-link:hover,
.nav-link.active {
    color: var(--ink);
}

/* === Main Content === */
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--app-gap);
}

/* === Year/Month Label === */
.date-label {
    font-size: 0.75rem;
    color: var(--muted);
    letter-spacing: 0.06em;
    font-family: var(--font-body);
}

/* === Hero Time Display === */
.hero-time {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 3.5rem;
    line-height: 1;
    letter-spacing: -0.04em;
    color: var(--ink);
    text-align: center;
}

/* === The accent indicator — a thin red line next to time === */
.time-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.accent-mark {
    width: 4px;
    height: 36px;
    background: var(--accent);
    opacity: 0;
    transition: opacity 0.4s ease;
}

.accent-mark.visible {
    opacity: 1;
}

/* === Punch Button — the only heavy element === */
.punch-btn {
    width: 120px;
    height: 120px;
    background: var(--ink);
    color: var(--surface);
    border: none;
    border-radius: 2px;
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}

.punch-btn:active {
    transform: scale(0.97);
    background: #333;
}

.punch-btn.state-waiting_out {
    background: var(--ink);
}

.punch-btn.state-done {
    background: var(--ink);
    color: var(--surface);
}

/* === Today Row === */
.today-row {
    display: flex;
    gap: calc(var(--grid) * 3);
    align-items: center;
    font-size: 0.8125rem;
    color: var(--muted);
}

.today-row .mono {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    color: var(--ink);
}

.today-sep {
    width: 1px;
    height: 12px;
    background: var(--faint);
}

/* === Progress Row === */
.progress-row {
    width: 100%;
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.progress-num {
    font-family: var(--font-mono);
    font-weight: 500;
    font-size: 0.9375rem;
    color: var(--ink);
}

.progress-label {
    font-size: 0.75rem;
    color: var(--muted);
    margin-right: auto;
}

.progress-bar {
    flex: 1;
    height: 18px;
    background: var(--faint);
    border-radius: 0;
    position: relative;
    display: flex;
    align-items: center;
    overflow: visible;
}

.progress-target {
    height: 100%;
    background: #C8C0B0;
    transition: width 0.5s ease;
    border-radius: 0;
    position: absolute;
    left: 0;
    top: 0;
}

.progress-real {
    position: absolute;
    top: -6px;
    bottom: -6px;
    width: 0;
    border-left: 1px solid var(--accent);
    z-index: 10;
    pointer-events: none;
}

.progress-marquee {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    background: linear-gradient(90deg, var(--ink), #C8C0B0, var(--ink));
    background-size: 200% 100%;
    z-index: 5;
    pointer-events: none;
    animation: marquee-flow 2.2s ease-in-out infinite;
}

@keyframes marquee-flow {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.progress-fill {
    height: 100%;
    background: var(--ink);
    transition: width 0.5s ease;
    border-radius: 0;
    position: absolute;
    left: 0;
    top: 0;
}

.progress-pct {
    position: relative;
    z-index: 3;
    font-family: var(--font-mono);
    font-size: 0.625rem;
    color: var(--muted);
    width: 100%;
    text-align: center;
    pointer-events: none;
}

/* === Section (used in sub-pages) === */
.section {
    width: 100%;
    margin-bottom: calc(var(--grid) * 3);
}

.section-title {
    font-size: 0.75rem;
    color: var(--muted);
    letter-spacing: 0.06em;
    margin-bottom: calc(var(--grid) * 2);
}

/* === Month Switcher === */
.month-switcher {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: calc(var(--grid) * 2);
    padding: calc(var(--grid) * 2) 0;
}

.month-switcher button {
    background: none;
    border: none;
    font-size: 1rem;
    color: var(--muted);
    cursor: pointer;
    padding: 8px;
    min-width: 44px;
    min-height: 44px;
    font-family: var(--font-body);
}

.month-switcher button:active {
    color: var(--ink);
}

.month-label {
    font-size: 0.9375rem;
    font-weight: 500;
    min-width: 100px;
    text-align: center;
    color: var(--ink);
}

/* === Record List === */
.record-list {
    list-style: none;
    width: 100%;
}

.record-item {
    display: flex;
    align-items: center;
    padding: 10px 0;
    font-size: 0.8125rem;
    border-bottom: 1px solid var(--faint);
    cursor: pointer;
    transition: background 0.15s;
}

.record-item:active {
    background: var(--faint);
}

.record-item.holiday,
.record-item.sunday {
    color: var(--muted);
}

.record-item.missing {
    color: var(--accent-dim);
}

.record-date {
    width: 48px;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--ink);
}

.record-weekday {
    width: 28px;
    font-size: 0.6875rem;
    color: var(--muted);
}

.record-times {
    flex: 1;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--ink);
}

.record-hours {
    width: 48px;
    text-align: right;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
}

/* === Calendar Grid === */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.calendar-header {
    text-align: center;
    font-size: 0.625rem;
    color: var(--muted);
    letter-spacing: 0.06em;
    padding: 8px 0 4px;
}

.calendar-cell {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.8125rem;
    cursor: pointer;
    color: var(--ink);
    position: relative;
    font-family: var(--font-mono);
    transition: background 0.1s;
}

.calendar-cell:active {
    background: var(--faint);
}

/* Priority: workday < sunday < holiday < selected (last wins) */
.calendar-cell.workday {
    background: #AAAAAA;
}

.calendar-cell.sunday {
    background: transparent;
    color: var(--muted);
    cursor: default;
}

.calendar-cell.holiday {
    background: var(--faint);
    color: var(--accent);
}

.calendar-cell.selected {
    background: var(--ink);
    color: var(--surface);
}

.calendar-cell .badge {
    font-size: 0.5rem;
    letter-spacing: 0.04em;
    margin-top: 1px;
    font-family: var(--font-body);
}

/* === Button Styles (sub-pages) === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border: 1px solid var(--faint);
    background: var(--surface);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 0.8125rem;
    cursor: pointer;
    min-height: 36px;
    transition: background 0.15s, border-color 0.15s;
}

.btn:active {
    background: var(--faint);
}

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

.btn-primary {
    background: var(--ink);
    color: var(--surface);
    border-color: var(--ink);
}

.btn-primary:active {
    background: #333;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.75rem;
    min-height: 32px;
}

/* === Month selector pills === */
.month-pills-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

.month-arrow {
    flex-shrink: 0;
    background: none;
    border: none;
    font-size: 0.875rem;
    color: var(--muted);
    cursor: pointer;
    padding: 4px;
    min-width: 32px;
    min-height: 32px;
    font-family: var(--font-body);
}

.month-arrow:active {
    color: var(--ink);
}

.month-pills {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding: 4px 0;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

.month-pills::-webkit-scrollbar {
    display: none;
}

.month-pill {
    border: 1px solid var(--faint);
    background: var(--surface);
    padding: 4px 12px;
    font-size: 0.75rem;
    font-family: var(--font-body);
    cursor: pointer;
    color: var(--muted);
    transition: all 0.15s;
}

.month-pill.active {
    background: var(--ink);
    color: var(--surface);
    border-color: var(--ink);
}

/* === Edit Overlay === */
.edit-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 200;
    align-items: center;
    justify-content: center;
}

.edit-overlay.open {
    display: flex;
}

.edit-panel {
    background: var(--surface);
    padding: calc(var(--grid) * 3);
    width: calc(100% - var(--grid) * 4);
    max-width: 320px;
}

.edit-panel h3 {
    font-size: 0.9375rem;
    font-weight: 500;
    margin-bottom: calc(var(--grid) * 2);
    color: var(--ink);
}

.edit-panel label {
    display: block;
    font-size: 0.75rem;
    color: var(--muted);
    margin-bottom: 4px;
    letter-spacing: 0.04em;
}

.edit-panel input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--faint);
    font-size: 1rem;
    font-family: var(--font-mono);
    margin-bottom: calc(var(--grid) * 2);
    background: var(--surface);
    color: var(--ink);
    outline: none;
}

.edit-panel input:focus {
    border-color: var(--ink);
}

.btn-row {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* === Utility === */
.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.text-muted { color: var(--muted); }
.mono { font-family: var(--font-mono); }

.legend-row {
    display: flex;
    gap: 16px;
    margin-top: 6px;
    font-size: 0.75rem;
    color: var(--muted);
    align-items: baseline;
}

.legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 2px;
    vertical-align: middle;
}

/* === Reduced motion === */
@media (prefers-reduced-motion: reduce) {
    .punch-btn,
    .nav-link,
    .progress-fill,
    .accent-mark {
        transition: none;
    }
}

/* === Live effective hours pulse (waiting_out state) === */
@keyframes pulse-fade {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.4; }
}

.pulse-live {
    animation: pulse-fade 2s ease-in-out infinite;
}
button:focus-visible,
a:focus-visible,
input:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
}

/* === Mobile phone sizing === */
@media (max-width: 374px) {
    .hero-time {
        font-size: 2.8rem;
    }
    .punch-btn {
        width: 100px;
        height: 100px;
    }
}
