/* Gorilla To Go styles. Colors come from docs/design.md. */

/* ---------- Fonts (in the app, so it works offline) ---------- */
@font-face { font-family: 'Outfit'; font-style: normal; font-weight: 400; font-display: swap; src: url('../fonts/outfit-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Outfit'; font-style: normal; font-weight: 500; font-display: swap; src: url('../fonts/outfit-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Outfit'; font-style: normal; font-weight: 600; font-display: swap; src: url('../fonts/outfit-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Outfit'; font-style: normal; font-weight: 700; font-display: swap; src: url('../fonts/outfit-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Playfair Display'; font-style: normal; font-weight: 700; font-display: swap; src: url('../fonts/playfair-display-latin-700-normal.woff2') format('woff2'); }

/* ---------- Color tokens ---------- */
:root {
    color-scheme: light;
    --bg: #f8f6f2;
    --bg-2: #f0ebe1;
    --card: #ffffff;
    --border: #e3dcd0;
    --text: #2b2927;
    --muted: #66615c;
    --primary: #596e57;
    --primary-hover: #455643;
    --on-primary: #ffffff;
    --link: #455643;
    --ok-bg: #e4ebe3;
    --ok-text: #3f513d;
    --fail-bg: #f5e1d8;
    --fail-text: #8a4a30;
    --shadow: 0 8px 24px rgba(43, 41, 39, 0.18);
    --font-ui: 'Outfit', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-title: 'Playfair Display', Georgia, serif;
    --radius: 12px;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #1c1a18;
        --bg-2: #242120;
        --card: #2b2826;
        --border: #3d3834;
        --text: #f0ebe1;
        --muted: #a8a19a;
        --primary: #8fa88c;
        --primary-hover: #a5bca2;
        --on-primary: #1c1a18;
        --link: #a5bca2;
        --ok-bg: #2f3a2e;
        --ok-text: #b5c9b2;
        --fail-bg: #3f2c24;
        --fail-text: #eab59c;
        --shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #1c1a18;
    --bg-2: #242120;
    --card: #2b2826;
    --border: #3d3834;
    --text: #f0ebe1;
    --muted: #a8a19a;
    --primary: #8fa88c;
    --primary-hover: #a5bca2;
    --on-primary: #1c1a18;
    --link: #a5bca2;
    --ok-bg: #2f3a2e;
    --ok-text: #b5c9b2;
    --fail-bg: #3f2c24;
    --fail-text: #eab59c;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

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

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 16px;
    line-height: 1.45;
}

a { color: var(--link); }
a:hover { color: var(--text); }

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

:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

.visually-hidden {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.noscript { padding: 24px; }

/* ---------- Screen layout ---------- */
.app { min-height: 100vh; min-height: 100dvh; }

.screen {
    max-width: 560px;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
}

.screen-body {
    flex: 1;
    padding: 20px 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.screen-footer {
    padding: 16px 20px calc(24px + env(safe-area-inset-bottom));
}

/* Top bar with a back button and a title (Add a site, help pages). */
.topbar {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.topbar h1 {
    margin: 0;
    font-family: var(--font-title);
    font-size: 24px;
    font-weight: 700;
}

/* Header row with the site switcher and the theme toggle. */
.header-row {
    padding: calc(12px + env(safe-area-inset-top)) 20px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.header-row--end { justify-content: flex-end; }

.page-title {
    margin: 0;
    font-family: var(--font-title);
    font-size: 34px;
    font-weight: 700;
    line-height: 1.1;
    overflow-wrap: anywhere;
}

/* ---------- Buttons ---------- */
.btn {
    min-height: 52px;
    padding: 0 20px;
    border: 0;
    border-radius: var(--radius);
    font-size: 17px;
    font-weight: 600;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    width: 100%;
}

.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); color: var(--on-primary); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-secondary { background: var(--card); color: var(--text); border: 1px solid var(--border); }

.btn-danger { background: var(--card); color: var(--fail-text); border: 1px solid var(--border); }

.btn-small {
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-2);
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.icon-btn {
    flex: none;
    width: 44px;
    height: 44px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--card);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    cursor: pointer;
}

.icon-btn--plain { border-color: transparent; background: transparent; }

.text-link {
    min-height: 44px;
    font-size: 15px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.text-link--small { min-height: 44px; font-size: 14px; justify-content: flex-start; }

/* ---------- Cards and chips ---------- */
.card {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.card-title { font-size: 16px; font-weight: 600; margin: 0; }

.chip {
    padding: 3px 12px;
    border-radius: 999px;
    background: var(--bg-2);
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
}

.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- Welcome ---------- */
.welcome-hero {
    flex: 1;
    padding: 24px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    text-align: center;
}

.welcome-hero img { width: 125px; height: 160px; object-fit: contain; }
.welcome-hero h1 { margin: 6px 0 0; font-family: var(--font-title); font-size: 34px; font-weight: 700; line-height: 1.1; }
.welcome-hero p { margin: 0; font-size: 17px; color: var(--muted); }

.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.steps li { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; line-height: 1.4; }

.step-num {
    flex: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--ok-bg);
    color: var(--ok-text);
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.note { display: flex; align-items: center; justify-content: center; gap: 6px; color: var(--muted); font-size: 13px; }

.welcome-actions { display: flex; flex-direction: column; gap: 12px; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 15px; font-weight: 600; }
.field-hint { font-size: 13px; color: var(--muted); }
.field-hint--error { color: var(--fail-text); font-weight: 600; }
.field-row { display: flex; gap: 12px; }
.field-row .field:first-child { flex: 1; }
.field-row .field:last-child { flex: 1.4; }

.input {
    width: 100%;
    min-height: 48px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    color: var(--text);
    font-size: 16px; /* 16 px or more: iPhone does not zoom in on focus. */
}

.input-group {
    min-height: 48px;
    padding: 0 4px 0 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    display: flex;
    align-items: center;
    gap: 4px;
}

.input-group:focus-within { outline: 3px solid var(--primary); outline-offset: 2px; }

.input-group input {
    flex: 1;
    min-width: 0;
    min-height: 46px;
    border: 0;
    outline: 0;
    background: transparent;
    font-size: 16px;
}

/* ---------- Checks ---------- */
.checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }

.check { display: flex; align-items: flex-start; gap: 10px; font-size: 15px; line-height: 1.4; }
.check-text { display: flex; flex-direction: column; gap: 2px; padding-top: 1px; }

.check-icon {
    flex: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-2);
    color: var(--muted);
}

.check--pass .check-icon { background: var(--ok-bg); color: var(--ok-text); }
.check--fail .check-icon { background: var(--fail-bg); color: var(--fail-text); }
.check--fail .check-label { color: var(--fail-text); font-weight: 600; }
.check--waiting .check-label { color: var(--muted); }

.spinner {
    width: 14px;
    height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
    .spinner { animation: none; }
}

.message-error {
    padding: 12px 14px;
    border-radius: var(--radius);
    background: var(--fail-bg);
    color: var(--fail-text);
    font-size: 15px;
}

.message-error:empty { display: none; }

/* ---------- Site screen ---------- */
.site-switch {
    min-height: 44px;
    max-width: 100%;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    color: var(--text);
    font-size: 15px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    min-width: 0;
}

.site-switch span:not(.dot) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }

.site-meta { margin: 0; color: var(--muted); font-size: 15px; overflow-wrap: anywhere; }

/* ---------- Bottom sheet (dialog) ---------- */
.sheet {
    width: 100%;
    max-width: 560px;
    margin: auto auto 0;
    padding: 0;
    border: 0;
    border-radius: 20px 20px 0 0;
    background: var(--card);
    color: var(--text);
    box-shadow: var(--shadow);
}

.sheet::backdrop { background: rgba(28, 26, 24, 0.5); }

.sheet-body {
    padding: 20px 20px calc(24px + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sheet-title { margin: 0; font-size: 20px; font-weight: 600; }

.sheet-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

.sheet-item {
    width: 100%;
    min-height: 52px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    text-align: left;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.sheet-item[aria-current="true"] { border-color: var(--primary); }

.sheet-item-text { display: flex; flex-direction: column; min-width: 0; }
.sheet-item-text span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Help pages ---------- */
.prose { display: block; font-size: 16px; line-height: 1.55; }
.prose > :first-child { margin-top: 0; }
.prose h2 { margin: 24px 0 8px; font-size: 20px; font-weight: 600; }
.prose ol, .prose ul { padding-left: 1.4em; }
.prose li { margin: 4px 0; }
.prose code { padding: 1px 6px; border-radius: 6px; background: var(--bg-2); font-size: 0.92em; overflow-wrap: anywhere; }
.prose pre { padding: 12px 14px; border-radius: var(--radius); background: var(--bg-2); overflow-x: auto; }
.prose pre code { padding: 0; background: none; }
