/* bookstack - design tokens, fonts and the base every page stands on.
 *
 * Warm paper and bookcloth by day, a reading lamp by night. Every colour is a
 * token here and nowhere else; a stylesheet that needs a new one adds it to
 * all three blocks below (light, explicit dark, and "follow the system" dark).
 * A colour missing from one of them is a bug: the page goes half light in the
 * dark (the rule from hmp-bookings).
 *
 * Dark mode is written twice on purpose: once for an explicit choice stored
 * with the account (<html data-theme="dark">), once for "no choice yet,
 * follow the system" - and an explicit "light" must win over a dark system.
 *
 * Fonts are self-hosted (the CSP allows no other origin): Literata for titles
 * and anything a book says about itself, Inter for the interface. Both OFL,
 * from @fontsource 5.3.0, latin subset - which covers Portuguese.
 */

@font-face { font-family: "Literata"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("../fonts/literata-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Literata"; font-style: italic; font-weight: 400; font-display: swap;
  src: url("../fonts/literata-latin-400-italic.woff2") format("woff2"); }
@font-face { font-family: "Literata"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("../fonts/literata-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("../fonts/inter-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("../fonts/inter-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("../fonts/inter-latin-600-normal.woff2") format("woff2"); }

:root {
  color-scheme: light;
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-book: "Literata", Georgia, "Times New Roman", serif;

  /* paper */
  --bg: #f4efe6;
  --surface: #fffcf6;
  --surface-2: #f9f4ea;
  --field: #fffdf9;
  --ink: #2a241d;
  --ink-soft: #6b5f50;
  --ink-faint: #8f8372;
  --line: #e2d8c6;
  --line-strong: #cfc1a9;
  /* bookcloth: an oxblood binding for the accent */
  --accent: #8c3b2f;
  --accent-hover: #74301f;
  --accent-soft: #f3e2dc;
  --on-accent: #fffaf4;
  --focus: #b0582f;
  /* states */
  --ok-bg: #e6f0e1;
  --ok-line: #bcd4b0;
  --ok-ink: #2f5424;
  --err-bg: #f8e4e0;
  --err-line: #e7bdb4;
  --err-ink: #7d2a1e;
  --warn-bg: #fbf1d6;
  --warn-line: #e6d39a;
  --warn-ink: #6a5314;
  --star: #c48a1c;
  --star-off: #ddd0bb;
  --chip-bg: #efe6d6;
  --chip-on: #8c3b2f;
  --on-chip-on: #fffaf4;
  --hover: rgba(140, 59, 47, .07);
  --scrim: rgba(30, 22, 14, .55);
  --shadow-1: 0 1px 2px rgba(60, 40, 20, .08), 0 1px 1px rgba(60, 40, 20, .04);
  --shadow-2: 0 6px 18px rgba(60, 40, 20, .14), 0 2px 4px rgba(60, 40, 20, .08);
  --shadow-3: 0 24px 60px rgba(30, 20, 10, .35), 0 8px 18px rgba(30, 20, 10, .2);
  /* wood, for the shelf view (shelf.css) */
  --wood: #a8784a;
  --wood-dark: #7a5330;
  --wood-light: #c49a6c;
  --wall: #ebe2d2;
  --plaque: #f6edd9;
  --plaque-ink: #4a3b29;
  /* Fixed on purpose, the same by day and by night: the ink of a drawn
     binding (a stand-in for a missing photo, book.css .book-standin) and the
     dark mat a photo is looked at on (the lightbox), and the page edges of
     the 3D book (shelf.css), and the camera level's yellow over a live
     picture (capture.css), should not change with
     the theme any more than a real book does. In all three blocks anyway,
     so the rule "every token in every block" holds. */
  --standin-light: #fffaf4;
  --standin-dark: #1f1812;
  --lb-bg: #14100c;
  --lb-ink: #f6efe2;
  --paper: #efe6d1;
  --paper-line: #d3c7aa;
  --level: #ffd23f;

  --radius: 10px;
  --radius-small: 6px;
  --gutter: 16px;
  --nav-h: 56px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  font-size: 16px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #15120f;
  --surface: #1f1a15;
  --surface-2: #26201a;
  --field: #1a1612;
  --ink: #ece3d4;
  --ink-soft: #b3a691;
  --ink-faint: #8a7e6c;
  --line: #352d24;
  --line-strong: #4a3f33;
  --accent: #d98a6f;
  --accent-hover: #e8a289;
  --accent-soft: #3a241d;
  --on-accent: #1d120d;
  --focus: #e8a289;
  --ok-bg: #1f2e1b;
  --ok-line: #3a5531;
  --ok-ink: #bfdcae;
  --err-bg: #3a1f1a;
  --err-line: #5e322a;
  --err-ink: #f2c3b8;
  --warn-bg: #352c16;
  --warn-line: #5f4f25;
  --warn-ink: #ecd99a;
  --star: #e3ad45;
  --star-off: #4a4034;
  --chip-bg: #2c251e;
  --chip-on: #d98a6f;
  --on-chip-on: #1d120d;
  --hover: rgba(217, 138, 111, .09);
  --scrim: rgba(0, 0, 0, .66);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-2: 0 6px 18px rgba(0, 0, 0, .5), 0 2px 4px rgba(0, 0, 0, .35);
  --shadow-3: 0 24px 60px rgba(0, 0, 0, .7), 0 8px 18px rgba(0, 0, 0, .5);
  --wood: #6b4a2c;
  --wood-dark: #4a321d;
  --wood-light: #87613d;
  --wall: #1b1713;
  --plaque: #3a3024;
  --plaque-ink: #e9dcc4;
  --standin-light: #fffaf4;
  --standin-dark: #1f1812;
  --lb-bg: #14100c;
  --lb-ink: #f6efe2;
  --paper: #efe6d1;
  --paper-line: #d3c7aa;
  --level: #ffd23f;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #15120f;
    --surface: #1f1a15;
    --surface-2: #26201a;
    --field: #1a1612;
    --ink: #ece3d4;
    --ink-soft: #b3a691;
    --ink-faint: #8a7e6c;
    --line: #352d24;
    --line-strong: #4a3f33;
    --accent: #d98a6f;
    --accent-hover: #e8a289;
    --accent-soft: #3a241d;
    --on-accent: #1d120d;
    --focus: #e8a289;
    --ok-bg: #1f2e1b;
    --ok-line: #3a5531;
    --ok-ink: #bfdcae;
    --err-bg: #3a1f1a;
    --err-line: #5e322a;
    --err-ink: #f2c3b8;
    --warn-bg: #352c16;
    --warn-line: #5f4f25;
    --warn-ink: #ecd99a;
    --star: #e3ad45;
    --star-off: #4a4034;
    --chip-bg: #2c251e;
    --chip-on: #d98a6f;
    --on-chip-on: #1d120d;
    --hover: rgba(217, 138, 111, .09);
    --scrim: rgba(0, 0, 0, .66);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-2: 0 6px 18px rgba(0, 0, 0, .5), 0 2px 4px rgba(0, 0, 0, .35);
    --shadow-3: 0 24px 60px rgba(0, 0, 0, .7), 0 8px 18px rgba(0, 0, 0, .5);
    --wood: #6b4a2c;
    --wood-dark: #4a321d;
    --wood-light: #87613d;
    --wall: #1b1713;
    --plaque: #3a3024;
    --plaque-ink: #e9dcc4;
    --standin-light: #fffaf4;
    --standin-dark: #1f1812;
    --lb-bg: #14100c;
    --lb-ink: #f6efe2;
  --paper: #efe6d1;
  --paper-line: #d3c7aa;
  --level: #ffd23f;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.5 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

h1, h2, h3 { font-family: var(--font-book); font-weight: 600; line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
code { font: .92em/1.4 ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
img { max-width: 100%; }
[hidden] { display: none !important; }

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

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

/* --- buttons and fields ------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45em;
  min-height: 40px; padding: 0 16px;
  border: 1px solid var(--line-strong); border-radius: 999px;
  background: var(--surface); color: var(--ink);
  font: 500 .95rem/1 var(--font-ui); text-decoration: none; cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--hover); color: var(--ink); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-danger { color: var(--err-ink); border-color: var(--err-line); }
.btn-danger:hover { background: var(--err-bg); color: var(--err-ink); }
.btn-small { min-height: 32px; padding: 0 12px; font-size: .875rem; }
.btn-block { width: 100%; }
.btn-icon { width: 40px; padding: 0; }
.btn-icon.btn-small { width: 32px; }
.btn svg, .icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor;
  stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: .875rem; font-weight: 500; color: var(--ink-soft); }
.field-hint { font-size: .8125rem; color: var(--ink-faint); }
.input, .select, .textarea {
  width: 100%; min-height: 42px; padding: 9px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-small);
  background: var(--field); color: var(--ink);
  font: 400 1rem/1.4 var(--font-ui);
}
.textarea { min-height: 120px; resize: vertical; }
.select { appearance: none; padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%),
                    linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%);
  background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%;
  background-size: 5px 5px; background-repeat: no-repeat; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--focus);
  box-shadow: 0 0 0 3px var(--accent-soft); }

.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
form.inline { display: inline; margin: 0; }

.flash, .form-error {
  padding: 10px 14px; border-radius: var(--radius-small); border: 1px solid; margin: 0 0 14px;
}
.flash-ok { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok-ink); }
.flash-error, .form-error { background: var(--err-bg); border-color: var(--err-line); color: var(--err-ink); }
.flash code { display: inline-block; margin: 4px 0; padding: 2px 8px; border-radius: 4px;
  background: var(--surface); color: var(--ink); user-select: all; word-break: break-all; }
.form-note { font-size: .875rem; color: var(--ink-soft); margin: 14px 0 0; }

/* --- the sign-in style pages (login, password, error, the review page) --- */

.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px var(--gutter); }
.auth-card {
  width: 100%; max-width: 400px; padding: 28px 26px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow-2);
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink);
  text-decoration: none; margin-bottom: 18px; }
.brand-mark { width: 30px; height: 30px; }
.brand-word { font: 600 1.2rem/1 var(--font-book); letter-spacing: .01em; }
.auth-langs { display: flex; gap: 6px; justify-content: center; margin-top: 18px; }
