/* The crew app (/app). Hand-written so it needs no build step on the hosting.
   Made for one hand, outdoors: big tap targets, strong contrast, light and dark. */

:root {
    --bg: #f4f5f2;
    --card: #ffffff;
    --text: #1c2118;
    --muted: #5d6658;
    --line: #dfe3da;
    --primary: #15803d;
    --primary-text: #ffffff;
    --button: #eceee8;
    --danger: #b91c1c;
    --radius: 14px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #111410;
        --card: #1b1f19;
        --text: #eef1ea;
        --muted: #a2ab9c;
        --line: #2d3329;
        --primary: #22a355;
        --button: #262b23;
        --danger: #f87171;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    padding-bottom: env(safe-area-inset-bottom);
}

a { color: var(--primary); }

h1 { font-size: 1.4rem; margin: 0 0 0.25rem; }
h2 { font-size: 1.05rem; margin: 0 0 0.6rem; }
p { margin: 0.25rem 0; }

.muted { color: var(--muted); }
.center { text-align: center; }
.pre { white-space: pre-line; }

/* Top bar */
.bar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: calc(0.6rem + env(safe-area-inset-top)) 1rem 0.6rem;
    background: var(--primary);
    color: var(--primary-text);
}

.bar-title { font-weight: 700; color: inherit; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.bar-button {
    appearance: none;
    border: 0;
    background: rgba(255, 255, 255, 0.18);
    color: inherit;
    font: inherit;
    font-size: 0.95rem;
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    text-decoration: none;
    white-space: nowrap;
}

.page {
    max-width: 40rem;
    margin: 0 auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.stack { display: flex; flex-direction: column; gap: 0.75rem; margin: 0; padding: 0; list-style: none; }

.card {
    display: block;
    background: var(--card);
    border: 1px solid var(--line);
    border-left: 6px solid var(--crew, var(--line));
    border-radius: var(--radius);
    padding: 0.9rem 1rem;
    color: inherit;
    text-decoration: none;
}

.card.link { font-weight: 600; font-size: 1.1rem; padding: 1.1rem 1rem; }

/* Buttons */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.75rem;
    padding: 0.5rem 1rem;
    border: 0;
    border-radius: 999px;
    background: var(--button);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.button.primary { background: var(--primary); color: var(--primary-text); }
.button.big { width: 100%; min-height: 3.25rem; font-size: 1.1rem; }

.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
.actions .button { flex: 1 1 auto; }

/* Day switcher */
.day-nav { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.day-nav .button { width: 3rem; font-size: 1.5rem; padding: 0; }
.day-nav-title { display: flex; flex-direction: column; align-items: center; }
.day-nav-title strong { font-size: 1.25rem; }

/* Visit cards */
.visit-main { display: flex; gap: 0.9rem; color: inherit; text-decoration: none; }
.visit-time { font-size: 1.3rem; font-weight: 800; min-width: 3.4rem; font-variant-numeric: tabular-nums; }
.visit-body { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.visit-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin-top: 0.35rem; font-size: 0.9rem; }
.visit.status-completed { opacity: 0.65; }

.badge { display: inline-block; padding: 0.1rem 0.55rem; border-radius: 999px; font-size: 0.8rem; font-weight: 700; background: var(--button); }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-gray { background: var(--button); color: var(--muted); }

/* Tasks */
.tasks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.tasks li { display: flex; align-items: center; gap: 0.75rem; padding: 0.7rem 0; border-top: 1px solid var(--line); }
.tasks li:first-child { border-top: 0; }
.tasks .tick { flex: none; width: 1.6rem; height: 1.6rem; border-radius: 0.45rem; border: 2px solid var(--line); display: inline-flex; align-items: center; justify-content: center; font-weight: 800; color: var(--primary-text); }
.tasks li.done .tick { background: var(--primary); border-color: var(--primary); }
.tasks li.done { color: var(--muted); }
.tasks li.done .task-title { text-decoration: line-through; }

/* Forms */
.login { display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: 2rem; gap: 0.25rem; }
.login form { width: 100%; margin-top: 1.5rem; text-align: left; }
.login-logo { border-radius: 18px; }

.field { display: flex; flex-direction: column; gap: 0.3rem; font-weight: 600; }
.field input {
    font: inherit;
    font-weight: 400;
    padding: 0.8rem 0.9rem;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--text);
}
.field input:focus { outline: 3px solid color-mix(in srgb, var(--primary) 35%, transparent); border-color: var(--primary); }

.field textarea {
    font: inherit;
    font-weight: 400;
    padding: 0.8rem 0.9rem;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--bg);
    color: var(--text);
    resize: vertical;
}

/* Ticking tasks: the whole row is the button */
.task-button {
    appearance: none;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    min-height: 2.5rem;
}
.task-button:disabled { opacity: 0.6; }
.task-text { display: flex; flex-direction: column; }
.task-text small { font-size: 0.8rem; text-decoration: none; }
.tasks li form { width: 100%; }

/* Photos */
.photo-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
.photo-buttons form { display: contents; }
.photo-button { gap: 0.3rem; padding: 0.5rem; font-size: 0.95rem; }
.photo-after { background: color-mix(in srgb, var(--primary) 22%, var(--button)); }
.photo-issue { background: color-mix(in srgb, var(--danger) 22%, var(--button)); }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr)); gap: 0.6rem; margin-top: 0.75rem; }
.photo { margin: 0; display: flex; flex-direction: column; gap: 0.3rem; }
.photo img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; background: var(--button); }
.photo figcaption { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; font-size: 0.78rem; }
.photo figcaption form { margin-left: auto; }
.photo-remove { appearance: none; border: 0; background: var(--button); color: var(--muted); width: 1.9rem; height: 1.9rem; border-radius: 999px; font: inherit; cursor: pointer; }
.photo-kind-after { background: #dcfce7; color: #166534; }
.photo-kind-issue { background: #fee2e2; color: #991b1b; }

.timeline p { margin: 0.15rem 0; }
.small { font-size: 0.875rem; margin-top: 0.4rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.error { color: var(--danger); font-weight: 600; }
.notice-error { background: #fee2e2; color: #991b1b; }
.notice { background: #dcfce7; color: #166534; padding: 0.75rem 1rem; border-radius: var(--radius); font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 2.5rem 1rem; }
