/* bookhome.ge base styles on top of tokens.css (a copy of docs/design/tokens.css): fonts, the base elements, and the
   design system's shared components (bh- classes). Each feature keeps its own styles in css/<feature>.css, which it
   registers as a Stylesheet. No inline styles anywhere: the CSP allows stylesheets from our origin only. */

/* Fonts (ADR-020 §18): Noto Sans cut into one file per script, the weight axis kept to 400–700, each file at most 40 KB.
   A page preloads only its language's script (App.razor), and the browser fetches another only for the characters
   that need it. Made from the design system's variable files with fonttools: varLib.instancer wght=400:700 wdth=100,
   then subset to these unicode ranges (Google Fonts' latin, latin-ext, cyrillic and cyrillic-ext, with ₾ in latin).
   "Noto Sans Fallback" is the local Arial (or Roboto) sized to Noto Sans's metrics, so text doesn't shift when the
   font swaps in. */
@font-face {
  font-family: "Noto Sans";
  src: url("../fonts/noto-sans-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+20BE, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Noto Sans";
  src: url("../fonts/noto-sans-latin-ext.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20BD, U+20BF-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Noto Sans";
  src: url("../fonts/noto-sans-cyrillic.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: "Noto Sans";
  src: url("../fonts/noto-sans-cyrillic-ext.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
  unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}

@font-face {
  font-family: "Noto Sans Georgian";
  src: url("../fonts/noto-sans-georgian.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
  unicode-range: U+10A0-10FF, U+1C90-1CBF, U+2D00-2D2F;
}

@font-face {
  font-family: "Noto Sans Fallback";
  src: local("Arial"), local("Roboto");
  size-adjust: 107.15%;
  ascent-override: 99.77%;
  descent-override: 27.35%;
  line-gap-override: 0%;
}

:root { --font-sans: "Noto Sans", "Noto Sans Georgian", "Noto Sans Fallback", system-ui, sans-serif; }

/* Base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--page); color: var(--ink-1);
  font-family: var(--font-sans); font-size: var(--text-body); line-height: var(--leading-body);
  font-weight: var(--weight-regular); font-synthesis: none; letter-spacing: 0;
}
h1, h2, h3, p, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: var(--primary); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { color: var(--primary-hover); text-decoration-thickness: 2px; }
button, input, select { font: inherit; color: inherit; letter-spacing: 0; }
:focus-visible { outline: 2px solid transparent; outline-offset: 2px; box-shadow: var(--focus-ring); }
[hidden] { display: none !important; }
summary { list-style: none; cursor: pointer; }
summary::-webkit-details-marker { display: none; }

/* Type */
.bh-t-display { font-size: var(--text-display); line-height: var(--leading-display); font-weight: var(--weight-bold); }
.bh-t-h1 { font-size: var(--text-h1); line-height: var(--leading-h1); font-weight: var(--weight-bold); }
.bh-t-h2 { font-size: var(--text-h2); line-height: var(--leading-h2); font-weight: var(--weight-bold); }
.bh-muted { color: var(--ink-2); }
.bh-small { font-size: var(--text-small); line-height: var(--leading-small); }
.bh-meta { color: var(--ink-3); font-size: var(--text-small); line-height: var(--leading-small); }
.bh-label { font-size: var(--text-small); line-height: var(--leading-small); font-weight: var(--weight-bold); }
.bh-hint { color: var(--ink-3); font-size: var(--text-small); line-height: var(--leading-small); }
.bh-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

/* Icons: Lucide at a 1.5 px stroke at every size */
.bh-icon { flex: none; width: 20px; height: 20px; stroke-width: 1.5; vertical-align: -0.25em; }
.bh-icon * { vector-effect: non-scaling-stroke; }
.bh-icon--16 { width: 16px; height: 16px; }
.bh-icon--24 { width: 24px; height: 24px; }
.bh-spin { animation: bh-spin 1s linear infinite; }
@keyframes bh-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .bh-spin { animation: none; } }

/* Buttons and links */
.bh-btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--target-min); min-width: var(--target-min); max-width: 100%; margin: 0; padding: var(--space-2) var(--space-4);
  border: 1px solid transparent; border-radius: var(--radius-control); background: transparent; color: var(--ink-1);
  font-size: var(--text-body); line-height: var(--leading-body); font-weight: var(--weight-bold);
  text-align: center; text-decoration: none; overflow-wrap: anywhere; cursor: pointer; touch-action: manipulation;
  transition: background-color var(--dur-press) var(--ease), color var(--dur-press) var(--ease);
}
.bh-btn:hover { text-decoration: none; }
.bh-btn--primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.bh-btn--primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--on-primary); }
.bh-btn--secondary { background: var(--card); border-color: var(--primary); color: var(--primary); }
.bh-btn--secondary:hover { background: var(--primary-soft); color: var(--primary-hover); }
.bh-btn--tertiary { padding-inline: var(--space-3); color: var(--primary); }
.bh-btn--tertiary:hover { background: var(--primary-soft); color: var(--primary-hover); }
.bh-btn--danger { background: var(--danger-ink); border-color: var(--danger-ink); color: var(--on-primary); }
.bh-btn--danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); color: var(--on-primary); }
.bh-btn--block { display: flex; width: 100%; }
.bh-btn--small { min-height: var(--target-min); padding: var(--space-1) var(--space-2); font-size: var(--text-small); line-height: var(--leading-small); }
.bh-btn[aria-disabled="true"] { background: var(--disabled-bg); border-color: var(--disabled-bg); color: var(--disabled-ink); cursor: not-allowed; }
.bh-btn--tertiary[aria-disabled="true"] { background: transparent; border-color: transparent; }
.bh-btn[aria-busy="true"] { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--on-primary); cursor: progress; }
.bh-arrow-link {
  display: inline-flex; align-items: center; gap: var(--space-2); justify-self: start; min-height: var(--target-min);
  font-weight: var(--weight-bold); text-decoration: none;
}

/* Wordmark */
.bh-wordmark { font-size: var(--text-h2); line-height: var(--leading-h2); font-weight: var(--weight-bold); color: var(--ink-1); text-decoration: none; white-space: nowrap; }
a.bh-wordmark { display: inline-flex; align-items: center; min-height: var(--target-min); }
a.bh-wordmark, a.bh-wordmark:hover { color: var(--ink-1); text-decoration: none; }

/* Menus: <details> with a <summary> button, so they work without JavaScript */
.bh-menu {
  display: grid; gap: 2px; min-width: 220px; margin: 0; padding: var(--space-2);
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-card); box-shadow: var(--shadow-overlay);
}
.bh-menu-pop { position: absolute; right: 0; top: calc(100% + var(--space-1)); z-index: 10; }
.bh-menu-item {
  appearance: none; display: flex; align-items: center; gap: var(--space-3); width: 100%; min-height: var(--target-min); margin: 0;
  padding: var(--space-2) var(--space-3); border: 0; border-radius: var(--radius-control); background: transparent;
  color: var(--ink-1); text-align: left; text-decoration: none; cursor: pointer;
}
.bh-menu-item:hover { background: var(--sunken); color: var(--ink-1); }
.bh-menu-item[aria-current="true"] { font-weight: var(--weight-bold); }
.bh-menu-item-tick { margin-left: auto; color: var(--primary); }

/* Page column, icon tile, copy field, chip, banner, card and form field */
.bh-page { display: grid; gap: var(--space-4); align-content: start; width: 100%; max-width: 560px; margin: 0 auto; padding: var(--space-8) var(--page-pad) var(--space-10); }
.bh-sys-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: var(--radius-card); background: var(--primary-soft); color: var(--primary); }
.bh-sys-icon--danger { background: var(--danger-bg); color: var(--danger-ink); }
.bh-sys-icon--info { background: var(--info-bg); color: var(--info-ink); }
.bh-copyf {
  padding: var(--space-3); border: 1px solid var(--border-input); border-radius: var(--radius-control); background: var(--card);
  font-family: var(--font-mono); font-size: var(--text-mono); line-height: var(--leading-mono); overflow-wrap: anywhere;
}
.bh-chip {
  display: inline-flex; align-items: center; gap: var(--space-1); min-height: 24px; padding: 2px 8px; vertical-align: middle;
  border: 1px solid var(--line); border-radius: var(--radius-pill); background: var(--neutral-bg); color: var(--neutral-ink);
}
.bh-chip--success { border-color: transparent; background: var(--success-bg); color: var(--success-ink); }
.bh-chip--neutral { border-color: var(--line); background: var(--neutral-bg); color: var(--neutral-ink); }
.bh-chip--info { border-color: transparent; background: var(--info-bg); color: var(--info-ink); }
.bh-chip--primary { border-color: transparent; background: var(--primary-soft); color: var(--primary); }
.bh-chip--warning { border-color: transparent; background: var(--warning-bg); color: var(--warning-ink); font-size: var(--text-label); line-height: var(--leading-label); }
.bh-chip--neutral, .bh-chip--info, .bh-chip--success, .bh-chip--primary { font-size: var(--text-label); line-height: var(--leading-label); }
.bh-banner { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-radius: var(--radius-card); background: var(--info-bg); }
.bh-banner > .bh-icon { margin-top: 2px; color: var(--info-ink); }
.bh-banner--error { background: var(--danger-bg); }
.bh-banner--error > .bh-icon { margin-top: 2px; color: var(--danger-ink); }
.bh-banner--warning { background: var(--warning-bg); }
.bh-banner--warning > .bh-icon { margin-top: 2px; color: var(--warning-ink); }
.bh-banner--success { background: var(--success-bg); }
.bh-banner--success > .bh-icon { margin-top: 2px; color: var(--success-ink); }
.bh-banner-body { display: grid; gap: var(--space-1); min-width: 0; }
.bh-banner-title { font-weight: var(--weight-bold); }
.bh-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-card); padding: var(--space-4); }
.bh-field { display: grid; gap: var(--space-2); }
.bh-input--num { font-variant-numeric: tabular-nums; }
.bh-select {
  width: 100%; min-height: 48px; padding: 11px 12px; border: 1px solid var(--border-input); border-radius: var(--radius-control);
  background: var(--card); color: var(--ink-1); font-size: var(--text-body); line-height: var(--leading-body);
}

/* Fields: label, error, text input, search (the design system's TextInput and Search) */
.bh-field-label { font-size: var(--text-small); line-height: var(--leading-small); font-weight: var(--weight-bold); color: var(--ink-1); }
.bh-error { display: flex; gap: var(--space-2); align-items: flex-start; font-size: var(--text-small); line-height: var(--leading-small); color: var(--danger-ink); }
.bh-input {
  -webkit-appearance: none; appearance: none;
  display: block; width: 100%; min-width: 0; min-height: var(--target-min); margin: 0;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-input); border-radius: var(--radius-control);
  background: var(--card); color: var(--ink-1);
  font-family: inherit; font-size: var(--text-body); line-height: var(--leading-body);
  transition: border-color var(--dur-press) var(--ease);
}
.bh-input::placeholder { color: var(--ink-3); opacity: 1; }
.bh-input:hover { border-color: var(--ink-2); }
.bh-input:focus { border-color: var(--primary); outline: 2px solid transparent; outline-offset: 2px; box-shadow: var(--focus-ring); }
.bh-input[aria-invalid="true"] { border-color: var(--danger-ink); box-shadow: inset 0 0 0 1px var(--danger-ink); }
.bh-input[aria-invalid="true"]:focus { box-shadow: inset 0 0 0 1px var(--danger-ink), var(--focus-ring); }
textarea.bh-input { min-height: 96px; resize: vertical; }
.bh-search { position: relative; }
.bh-search > .bh-icon { position: absolute; left: var(--space-3); top: 12px; color: var(--ink-2); pointer-events: none; }
.bh-search > .bh-input { padding-left: var(--space-10); }

/* Icon-only buttons: close, back and copy only. Always with aria-label. */
.bh-icon-btn {
  -webkit-appearance: none; appearance: none;
  display: inline-grid; place-items: center; flex: none;
  width: var(--target-min); height: var(--target-min); margin: 0; padding: 0;
  border: 0; border-radius: var(--radius-control); background: transparent; color: var(--ink-1); cursor: pointer;
}
.bh-icon-btn:hover { background: var(--sunken); }

/* Switch: an on/off setting, on <input type="checkbox" role="switch"> */
.bh-switch { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); min-height: var(--target-min); cursor: pointer; }
.bh-switch-text { display: grid; min-width: 0; }
.bh-switch-name { font-weight: var(--weight-bold); }
.bh-switch-desc { color: var(--ink-2); font-size: var(--text-small); line-height: var(--leading-small); }
.bh-switch-control { position: relative; flex: none; display: inline-flex; align-items: center; gap: var(--space-2); }
.bh-switch-input { position: absolute; left: 0; top: 50%; width: 44px; height: 24px; margin: -12px 0 0; opacity: 0; cursor: pointer; }
.bh-switch-track { position: relative; flex: none; width: 44px; height: 24px; border-radius: var(--radius-pill); background: var(--border-input); transition: background-color var(--dur-fade) var(--ease); }
.bh-switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: var(--radius-pill); background: var(--card); transition: transform var(--dur-fade) var(--ease); }
.bh-switch-input:checked + .bh-switch-track { background: var(--primary); }
.bh-switch-input:checked + .bh-switch-track::after { transform: translateX(20px); }
.bh-switch-input:focus-visible + .bh-switch-track { box-shadow: var(--focus-ring); }
.bh-switch-state { min-width: 3ch; color: var(--ink-2); font-size: var(--text-small); line-height: var(--leading-small); }
.bh-switch-on { display: none; }
.bh-switch-input:checked ~ .bh-switch-state .bh-switch-on { display: inline; }
.bh-switch-input:checked ~ .bh-switch-state .bh-switch-off { display: none; }
@media (prefers-reduced-motion: reduce) {
  .bh-switch-track::after { transition: none; }
}

/* Bottom sheet and dialog: a native modal <dialog>, a sheet on phones and centred from 768 px */
@keyframes bh-fade-in { from { opacity: 0; } }
@keyframes bh-sheet-in { from { transform: translateY(100%); } }
.bh-sheet {
  position: fixed; inset: auto 0 0 0;
  width: 100%; max-width: none; max-height: calc(100dvh - var(--space-12));
  margin: 0; padding: 0; border: 0; border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
  background: var(--card); color: var(--ink-1); box-shadow: var(--shadow-overlay); overflow: hidden;
}
.bh-sheet[open] { display: flex; flex-direction: column; animation: bh-sheet-in var(--dur-sheet-in) var(--ease); }
.bh-sheet::backdrop { background: var(--scrim); }
@media (min-width: 768px) {
  .bh-sheet { inset: 0; width: min(560px, calc(100% - var(--space-12))); height: fit-content; max-height: calc(100dvh - var(--space-16)); margin: auto; border-radius: var(--radius-card); }
  .bh-sheet.bh-dialog--confirm { width: min(440px, calc(100% - var(--space-12))); }
  .bh-sheet[open] { animation-name: bh-fade-in; }
}
@media (prefers-reduced-motion: reduce) {
  .bh-sheet[open] { animation: bh-fade-in var(--dur-fade) var(--ease); }
}
.bh-sheet-head { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4); border-bottom: 1px solid var(--line); }
.bh-sheet-title { flex: 1 1 auto; min-width: 0; font-size: var(--text-h3); line-height: var(--leading-h3); font-weight: var(--weight-bold); }
.bh-sheet-body { flex: 1 1 auto; display: grid; gap: var(--space-4); align-content: start; padding: var(--space-4); overflow: auto; }
.bh-sheet-foot { display: flex; flex-wrap: wrap; gap: var(--space-2); padding: var(--space-3) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); background: var(--card); }
.bh-sheet-foot > .bh-btn { flex: 1 1 140px; }

/* Save bar: the sticky action bar of task pages */
.bh-savebar { position: sticky; bottom: 0; z-index: 3; display: grid; gap: var(--space-1); align-content: center; min-height: var(--shell-actionbar-h); padding: var(--space-3) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom, 0px)); background: var(--card); border-top: 1px solid var(--line); box-shadow: var(--shadow-overlay); }
.bh-savebar-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.bh-savebar-status { flex: 1 1 140px; min-width: 0; color: var(--ink-2); font-size: var(--text-small); line-height: var(--leading-small); }
.bh-savebar-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-left: auto; }
