/*
 * AvailaBooks brand layer for app pages (see brand.md at the repo root).
 * Loaded after the shared book CSS (styles/css.css, synced from
 * tools/system-files), so it re-points that file's tokens at the brand
 * palette instead of editing the shared copy.
 *
 * App pages stay light-only for now: the shared book CSS hard-codes many
 * light colors, so the dark-mode overrides from brand.md aren't applied here.
 */

:root {
  /* Brand tokens — brand.md §2 */
  --avb-ink: #1B2A4A;
  --avb-ai: #C2662D;
  --avb-ai-text: #A4521F;
  --avb-tld: #7A8499;
  --avb-navy-ground: #16233D;
  --bg: #FFFFFF;
  --surface: #F5F6F8;
  --fg: #1A1F2B;
  --muted: #5D6575;
  --line: #DCE0E7;
  --link: #1B2A4A;
  --font-serif: "Alegreya", Georgia, "Times New Roman", serif;
  --font-sans: "Alegreya Sans", "Segoe UI", system-ui, sans-serif;

  /* Shared book CSS tokens, mapped onto the brand. Navy is the primary
     action color, so the old blue "accent" becomes Navy. */
  --page-bg: var(--bg);
  --surface-soft: color-mix(in srgb, var(--line) 45%, var(--surface));
  --surface-muted: var(--line);
  --text: var(--fg);
  --text-muted: var(--muted);
  --heading: var(--avb-ink);
  --accent: var(--avb-ink);
  --accent-strong: var(--avb-navy-ground);
  --accent-soft: color-mix(in srgb, var(--avb-ink) 10%, var(--bg));
  --border: var(--line);
  --shadow-sm: 0 1px 2px color-mix(in srgb, var(--avb-navy-ground) 8%, transparent);
  --shadow-md: 0 12px 30px color-mix(in srgb, var(--avb-navy-ground) 12%, transparent);
  --shadow-lg: 0 24px 60px color-mix(in srgb, var(--avb-navy-ground) 16%, transparent);
}

/* Wordmark — brand.md §1, unchanged */
.avb-logo {
  font-family: "Alegreya", Georgia, "Times New Roman", serif;
  font-weight: 500;
  font-size: 1.5rem;
  letter-spacing: 0.005em;
  line-height: 1;
  color: var(--avb-ink);
  text-decoration: none;
  white-space: nowrap;
}
.avb-logo .avb-ai  { color: var(--avb-ai); }
.avb-logo .avb-tld { color: var(--avb-tld); }
/* The shared book CSS styles every link (a:visited is indigo, a:hover adds a
   tinted box). Those selectors outrank `.avb-logo`, so the wordmark link
   turned indigo once "/" was visited. Keep it in brand colors in every state. */
a.avb-logo:link,
a.avb-logo:visited,
a.avb-logo:hover,
a.avb-logo:active {
  color: var(--avb-ink);
  background: transparent;
  text-decoration: none;
}

/* Typography — brand.md §3. Only Alegreya and Alegreya Sans. */
body {
  font-family: var(--font-sans);
  font-size: calc(1.0625rem * var(--font-zoom, 1));
  line-height: 1.55;
  color: var(--fg);
  background: var(--bg);
}
h1, h2, h3, h4, .book-title {
  font-family: var(--font-serif);
  color: var(--avb-ink);
  text-wrap: balance;
}
h1, h2 { font-weight: 500; }
h3, h4 { font-weight: 700; }
.learning .objectives,
.monaco-bar-label {
  font-family: var(--font-sans);
}
div.learning {
  font-family: var(--font-serif);
}
.book-text {
  font-family: var(--font-serif);
  font-size: 1.1875rem;
  line-height: 1.65;
  max-width: 68ch;
}

/* Copper marks AI features only (e.g. AI-scored assessments). */
.avb-ai-label {
  font-size: 0.75rem;
  line-height: 1.3;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--avb-ai-text);
}

/*
 * Accessibility (WCAG 2.1 AA). These override the shared book CSS here
 * rather than in styles/css.css, which is synced from tools/system-files.
 */
:root {
  /* #B91C1C: 5.98:1 on --surface, 6.47:1 on white (was #dc2626, 4.47:1). */
  --danger: #B91C1C;
  /* Text-field borders (1.4.11): #7A8499 is 3.48:1 on --surface, 3.76:1 on
     white. --line (#DCE0E7, ~1.2:1) stays for dividers and card edges. */
  --field-border: #7A8499;
  /* Keyboard focus ring: Navy, 13–14:1 on the app's light grounds. */
  --focus-ring: var(--avb-ink);
}

/* One visible focus indicator for every control (2.4.7). Components may
   change border color on focus, but must not remove this outline. */
a:focus-visible,
button:focus-visible,
summary:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* The shared book CSS draws the search field with a faint border and a
   near-invisible focus glow (and outline:none). */
#search {
  border-color: var(--field-border);
}
#search:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  box-shadow: none;
}

/* Links in running text are underlined, not told apart by color alone
   (the shared book CSS sets text-decoration:none on every link). */
.post-body :is(p, li, dd, td, blockquote, figcaption) a:not([class]):link,
.post-body :is(p, li, dd, td, blockquote, figcaption) a:not([class]):visited {
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

/* "Skip to content": off-screen until it gets keyboard focus. */
.skip-link {
  position: fixed;
  left: 0.75rem;
  top: -10rem;
  z-index: 100;
  padding: 0.5rem 0.9rem;
  border-radius: 0.375rem;
  background: var(--avb-ink);
  color: #FFFFFF;
  font-weight: 700;
  text-decoration: none;
}
a.skip-link:link,
a.skip-link:visited {
  color: #FFFFFF;
  background: var(--avb-ink);
}
.skip-link:focus,
.skip-link:focus-visible {
  top: 0.5rem;
  outline: 2px solid #FFFFFF;
  outline-offset: -4px;
}
#main:focus {
  outline: none;
}

/* Text for screen readers only (e.g. live filter result counts). */
.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;
}
