/* ============================================================
   chores.martinuhlar.cz  —  domácí práce
   estetika: krémová + tlumená šalvěj, Fraunces + Plus Jakarta
   ============================================================ */

:root {
    /* Barevná paleta */
    --bg: #f5f1e8;
    --bg-soft: #ede7d7;
    --card: #ffffff;
    --card-warm: #fbf8f1;
    --ink: #2b2823;
    --ink-soft: #4a4640;
    --ink-muted: #8a8175;
    --line: #e6dec9;
    --line-soft: #f0e9d8;

    /* Akcenty (stavy) */
    --sage: #6b8e6e;
    --sage-deep: #4d6f51;
    --sage-soft: #dde6dd;
    --sage-faint: #ecf1ec;

    --amber: #c89849;
    --amber-soft: #f3e6c8;

    --terra: #b8654a;
    --terra-soft: #f0d6c8;

    --terra-deep: #8f4632;
    --terra-deep-soft: #e6c4b6;

    --slate: #7a8694;
    --slate-soft: #e2e5e8;

    /* Stíny */
    --shadow-sm: 0 1px 2px rgba(43, 40, 35, 0.04),
                 0 1px 4px rgba(43, 40, 35, 0.04);
    --shadow-md: 0 2px 6px rgba(43, 40, 35, 0.06),
                 0 8px 24px rgba(43, 40, 35, 0.06);
    --shadow-lg: 0 8px 24px rgba(43, 40, 35, 0.08),
                 0 24px 48px rgba(43, 40, 35, 0.10);

    /* Tvary */
    --r-sm: 8px;
    --r-md: 14px;
    --r-lg: 20px;
    --r-xl: 28px;

    /* Typografie */
    --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
    --font-body: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

    /* Rozměry */
    --content-max: 640px;
    --pad: 18px;
    --safe-top: env(safe-area-inset-top, 0);
    --safe-bot: env(safe-area-inset-bottom, 0);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overscroll-behavior-y: none;
}

body {
    min-height: 100vh;
    background-image:
        radial-gradient(circle at 12% 8%, rgba(107, 142, 110, 0.05), transparent 40%),
        radial-gradient(circle at 88% 92%, rgba(184, 101, 74, 0.04), transparent 45%);
    padding-bottom: calc(var(--safe-bot) + 96px);
}

a { color: inherit; }

button, input, textarea, select {
    font: inherit;
    color: inherit;
}

button {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

::selection { background: var(--sage-soft); }

/* ============================================================
   TOPBAR
   ============================================================ */

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    background: rgba(245, 241, 232, 0.94);
    backdrop-filter: saturate(140%) blur(10px);
    -webkit-backdrop-filter: saturate(140%) blur(10px);
    border-bottom: 1px solid var(--line-soft);
    padding-top: var(--safe-top);
}

.topbar-inner {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 14px var(--pad);
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand { flex: 1; min-width: 0; }

.brand h1 {
    font-family: var(--font-display);
    font-variation-settings: "opsz" 144, "SOFT" 80, "wght" 500;
    font-weight: 500;
    font-size: 1.55rem;
    line-height: 1.05;
    letter-spacing: -0.01em;
    margin: 0;
    color: var(--ink);
}

.brand-sub {
    margin: 2px 0 0;
    font-size: 0.86rem;
    color: var(--ink-muted);
    letter-spacing: 0.005em;
}

.brand-sub .warn {
    color: var(--terra-deep);
    font-weight: 600;
}

.topbar-logout,
.topbar-back,
.topbar-edit {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border-radius: var(--r-sm);
    color: var(--ink-soft);
    transition: background 0.15s, color 0.15s;
    text-decoration: none;
}

.topbar-logout:hover,
.topbar-back:hover,
.topbar-edit:hover {
    background: var(--line-soft);
    color: var(--ink);
}

.topbar-back { font-size: 0.95rem; font-weight: 500; }

/* ============================================================
   FILTRY (pills)
   ============================================================ */

.filters {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 14px var(--pad) 4px;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }

.pill {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 999px;
    background: transparent;
    color: var(--ink-soft);
    font-size: 0.88rem;
    font-weight: 500;
    border: 1px solid var(--line);
    transition: all 0.15s;
}

.pill:hover:not(:disabled):not(.is-active) {
    background: var(--card-warm);
    border-color: var(--ink-muted);
}

.pill.is-active {
    background: var(--ink);
    color: var(--bg);
    border-color: var(--ink);
}

.pill:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pill-count {
    display: inline-block;
    min-width: 16px;
    text-align: center;
    font-size: 0.78rem;
    opacity: 0.7;
    font-variant-numeric: tabular-nums;
}

/* ============================================================
   CHORE LIST
   ============================================================ */

.chore-list {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 12px var(--pad) 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chore {
    position: relative;
    display: flex;
    align-items: stretch;
    background: var(--card);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: opacity 0.25s, transform 0.25s;
}

.chore.is-hidden {
    display: none;
}

.chore.is-completing {
    transform: scale(0.985);
    opacity: 0.7;
}

.chore-body {
    flex: 1;
    display: flex;
    gap: 0;
    padding: 0;
    text-decoration: none;
    color: inherit;
    min-width: 0;
}

.chore-stripe {
    width: 5px;
    flex-shrink: 0;
    background: var(--sage);
}

.chore[data-state="never"] .chore-stripe { background: var(--slate); }
.chore[data-state="fresh"] .chore-stripe { background: var(--sage); }
.chore[data-state="approaching"] .chore-stripe { background: var(--amber); }
.chore[data-state="overdue"] .chore-stripe { background: var(--terra); }
.chore[data-state="very_overdue"] .chore-stripe {
    background: repeating-linear-gradient(
        45deg,
        var(--terra-deep) 0 6px,
        #732e1d 6px 12px
    );
}

.chore-text {
    flex: 1;
    padding: 14px 12px 14px 14px;
    min-width: 0;
}

.chore-name {
    font-family: var(--font-display);
    font-variation-settings: "opsz" 72, "SOFT" 60, "wght" 500;
    font-weight: 500;
    font-size: 1.08rem;
    line-height: 1.2;
    letter-spacing: -0.005em;
    margin: 0 0 4px;
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.chore-meta {
    margin: 0 0 6px;
    font-size: 0.78rem;
    color: var(--ink-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.chore-cat {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--ink-soft);
}

.dot { opacity: 0.5; }

.chore-status {
    margin: 0;
    font-size: 0.92rem;
    font-weight: 500;
}

.chore-status--never { color: var(--slate); }
.chore-status--fresh { color: var(--sage-deep); }
.chore-status--approaching { color: #8a6520; }
.chore-status--overdue { color: var(--terra); font-weight: 600; }
.chore-status--very_overdue { color: var(--terra-deep); font-weight: 700; }

.chore-check {
    flex-shrink: 0;
    width: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--sage-deep);
    border-left: 1px solid var(--line-soft);
    transition: background 0.15s, transform 0.1s;
    position: relative;
}

.chore-check:active {
    background: var(--sage-faint);
    transform: scale(0.94);
}

.chore-check.is-flashing {
    background: var(--sage);
    color: white;
    animation: flash 0.45s ease-out;
}

@keyframes flash {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.18); background: var(--sage-deep); }
    100% { transform: scale(1); }
}

/* ============================================================
   EMPTY STATE
   ============================================================ */

.empty-state {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 40px var(--pad);
}

.empty-card {
    background: var(--card);
    border-radius: var(--r-lg);
    padding: 32px 24px;
    box-shadow: var(--shadow-md);
    text-align: center;
}

.empty-card h2 {
    font-family: var(--font-display);
    font-variation-settings: "opsz" 144, "SOFT" 80, "wght" 500;
    font-weight: 500;
    font-size: 1.6rem;
    margin: 0 0 12px;
    letter-spacing: -0.01em;
}

.empty-card p {
    color: var(--ink-soft);
    margin: 0 0 24px;
    line-height: 1.55;
}

.empty-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ============================================================
   DETAIL
   ============================================================ */

.detail {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 0;
}

.detail-hero {
    padding: 28px var(--pad) 24px;
    border-bottom: 1px solid var(--line-soft);
    position: relative;
}

.detail-hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: var(--pad);
    right: var(--pad);
    height: 3px;
    border-radius: 0 0 2px 2px;
    background: var(--sage);
}

.detail-hero--never::before { background: var(--slate); }
.detail-hero--fresh::before { background: var(--sage); }
.detail-hero--approaching::before { background: var(--amber); }
.detail-hero--overdue::before { background: var(--terra); }
.detail-hero--very_overdue::before {
    background: repeating-linear-gradient(45deg, var(--terra-deep) 0 6px, #732e1d 6px 12px);
}

.detail-cat {
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--ink-muted);
    margin: 0 0 6px;
}

.detail-title {
    font-family: var(--font-display);
    font-variation-settings: "opsz" 144, "SOFT" 100, "wght" 500;
    font-weight: 500;
    font-size: 1.9rem;
    line-height: 1.15;
    letter-spacing: -0.015em;
    margin: 0 0 10px;
}

.detail-status {
    margin: 0 0 2px;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--ink);
}

.detail-hero--fresh .detail-status { color: var(--sage-deep); }
.detail-hero--approaching .detail-status { color: #8a6520; }
.detail-hero--overdue .detail-status { color: var(--terra); }
.detail-hero--very_overdue .detail-status { color: var(--terra-deep); }
.detail-hero--never .detail-status { color: var(--slate); }

.detail-cycle {
    margin: 0;
    font-size: 0.85rem;
    color: var(--ink-muted);
}

.detail-note {
    margin: 14px 0 0;
    padding: 12px 14px;
    background: var(--card-warm);
    border-left: 3px solid var(--line);
    border-radius: 0 var(--r-sm) var(--r-sm) 0;
    font-size: 0.94rem;
    color: var(--ink-soft);
    line-height: 1.55;
}

.detail-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.detail-actions .btn-primary { flex: 1; }

/* Stats */
.detail-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    padding: 0 var(--pad);
    border-bottom: 1px solid var(--line-soft);
}

.stat {
    padding: 18px 8px;
    text-align: center;
    border-right: 1px solid var(--line-soft);
}
.stat:last-child { border-right: 0; }

.stat-label {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--ink-muted);
    margin-bottom: 4px;
    font-weight: 600;
}

.stat-value {
    display: block;
    font-family: var(--font-display);
    font-variation-settings: "opsz" 72, "SOFT" 60, "wght" 500;
    font-size: 1.5rem;
    letter-spacing: -0.01em;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.stat-value small {
    font-family: var(--font-body);
    font-size: 0.75rem;
    color: var(--ink-muted);
    font-weight: 500;
    margin-left: 2px;
}

/* History */
.history {
    padding: 22px var(--pad) 8px;
}

.section-h {
    font-family: var(--font-display);
    font-variation-settings: "opsz" 144, "SOFT" 80, "wght" 500;
    font-weight: 500;
    font-size: 1.15rem;
    letter-spacing: -0.01em;
    margin: 0 0 14px;
    color: var(--ink);
}

.history-list {
    list-style: none;
    margin: 0;
    padding: 0;
    background: var(--card);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line-soft);
}

.history-item:last-child { border-bottom: 0; }

.history-main { flex: 1; min-width: 0; }

.history-date {
    margin: 0;
    font-weight: 500;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.history-time {
    margin-left: 8px;
    font-size: 0.85rem;
    color: var(--ink-muted);
    font-weight: 400;
}

.history-gap {
    margin: 2px 0 0;
    font-size: 0.8rem;
    color: var(--ink-muted);
}

.history-actions { display: flex; gap: 2px; }

.icon-btn {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-sm);
    color: var(--ink-muted);
    transition: background 0.15s, color 0.15s;
}

.icon-btn:hover {
    background: var(--bg-soft);
    color: var(--ink);
}

.icon-btn--danger:hover {
    background: var(--terra-soft);
    color: var(--terra-deep);
}

.muted {
    color: var(--ink-muted);
    font-style: italic;
    text-align: center;
    padding: 16px;
}

/* Danger zone */
.danger-zone {
    padding: 32px var(--pad) 24px;
}

/* ============================================================
   LOGIN
   ============================================================ */

.page-login {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 24px;
    padding-bottom: 24px;
}

.login-wrap {
    width: 100%;
    max-width: 380px;
}

.login-card {
    background: var(--card);
    border-radius: var(--r-xl);
    padding: 36px 28px 30px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.login-ornament {
    color: var(--sage);
    margin-bottom: 16px;
}
.login-ornament svg { width: 80px; height: 12px; }

.login-title {
    font-family: var(--font-display);
    font-variation-settings: "opsz" 144, "SOFT" 100, "wght" 500;
    font-weight: 500;
    font-size: 1.8rem;
    margin: 0 0 4px;
    letter-spacing: -0.015em;
}

.login-sub {
    margin: 0 0 28px;
    color: var(--ink-muted);
    font-size: 0.92rem;
}

.login-form { display: flex; flex-direction: column; gap: 16px; }

/* ============================================================
   FORM FIELDS
   ============================================================ */

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    text-align: left;
}

.field-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--ink-soft);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.field input,
.field textarea {
    background: var(--card-warm);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    padding: 11px 12px;
    font-size: 1rem;
    transition: border-color 0.15s, background 0.15s;
    width: 100%;
    font-family: var(--font-body);
}

.field input:focus,
.field textarea:focus {
    outline: 0;
    border-color: var(--sage);
    background: var(--card);
    box-shadow: 0 0 0 3px var(--sage-faint);
}

.field textarea {
    resize: vertical;
    min-height: 60px;
}

.form-error {
    color: var(--terra-deep);
    background: var(--terra-soft);
    padding: 10px 12px;
    border-radius: var(--r-sm);
    font-size: 0.9rem;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 18px;
    border-radius: var(--r-sm);
    font-size: 0.96rem;
    font-weight: 600;
    letter-spacing: 0.005em;
    transition: all 0.15s;
    border: 1px solid transparent;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
    background: var(--sage);
    color: white;
}
.btn-primary:hover { background: var(--sage-deep); }

.btn-ghost {
    background: transparent;
    color: var(--ink-soft);
    border-color: var(--line);
}
.btn-ghost:hover { background: var(--card-warm); border-color: var(--ink-muted); }

.btn-danger {
    background: transparent;
    color: var(--terra-deep);
    border-color: var(--terra-soft);
}
.btn-danger:hover { background: var(--terra-soft); }

.btn-block { width: 100%; }

.btn-large { padding: 14px 20px; font-size: 1rem; }

/* ============================================================
   FAB
   ============================================================ */

.fab {
    position: fixed;
    right: 20px;
    bottom: calc(20px + var(--safe-bot));
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: var(--ink);
    color: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(43, 40, 35, 0.25),
                0 8px 32px rgba(43, 40, 35, 0.15);
    z-index: 25;
    transition: transform 0.15s, box-shadow 0.2s;
}

.fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(43, 40, 35, 0.30),
                0 12px 40px rgba(43, 40, 35, 0.18);
}

.fab:active { transform: scale(0.94); }

/* ============================================================
   BOTTOM SHEET
   ============================================================ */

.sheet {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.sheet[hidden] { display: none; }

.sheet-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(43, 40, 35, 0.42);
    animation: fadeIn 0.2s ease-out;
}

.sheet-panel {
    position: relative;
    width: 100%;
    max-width: var(--content-max);
    background: var(--bg);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    padding: 12px var(--pad) calc(var(--safe-bot) + 24px);
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
    max-height: 92vh;
    overflow-y: auto;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

.sheet-grip {
    width: 38px;
    height: 4px;
    background: var(--line);
    border-radius: 2px;
    margin: 0 auto 14px;
}

.sheet-title {
    font-family: var(--font-display);
    font-variation-settings: "opsz" 144, "SOFT" 80, "wght" 500;
    font-weight: 500;
    font-size: 1.4rem;
    letter-spacing: -0.01em;
    margin: 0 0 18px;
    text-align: center;
}

.sheet-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.sheet-actions {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.sheet-actions .btn { flex: 1; }

/* ============================================================
   TOAST
   ============================================================ */

.toast {
    position: fixed;
    bottom: calc(90px + var(--safe-bot));
    left: 50%;
    transform: translateX(-50%);
    background: var(--ink);
    color: var(--bg);
    padding: 11px 18px;
    border-radius: var(--r-sm);
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    z-index: 60;
    animation: toastIn 0.25s ease-out;
    max-width: calc(100% - 32px);
    text-align: center;
}

.toast[hidden] { display: none; }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(10px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ============================================================
   DESKTOP
   ============================================================ */

@media (min-width: 720px) {
    body { padding-bottom: calc(var(--safe-bot) + 60px); }
    .topbar-inner { padding: 18px var(--pad); }
    .brand h1 { font-size: 1.8rem; }
    .chore-list { padding-top: 16px; gap: 12px; }
    .chore-name { font-size: 1.15rem; }
    .detail-title { font-size: 2.2rem; }
    .fab { width: 56px; height: 56px; right: max(20px, calc((100vw - var(--content-max)) / 2 - 80px)); }
}
