/* first-steps-shell.css - The Excellent Reader global header, First Steps sub-bar, quiet footer and Studio Mode
 * controls for every page under /first-steps/.
 *
 * Synced from greg-read-right-web-system (site/assets/tokens.css, site/assets/site-shell.css, and the Studio dialog
 * styles in site/index.html; docs/site-navigation.md Sections 3 and 5). Web System's file wraps these rules in
 * @layer blocks; here they are unlayered, so that the First Steps pages' own plain element rules (a, button) cannot
 * override them. Re-sync by copying those blocks again, not by editing rules here one by one.
 */

/* ---------- tokens (site/assets/tokens.css) ---------- */
:root {
  color-scheme: light;

  /* Tier 1: Core palette */
  --rr-color-paper: #fcfaf4;
  --rr-color-header-bg: #fffdf8;
  --rr-color-wash: #eef3eb;
  --rr-color-surface: #ffffff;
  --rr-color-surface-muted: #f6f5ef;
  --rr-color-ink: #233a37;
  --rr-color-ink-nav: #314b45;
  --rr-color-muted: #546763;
  --rr-color-unavailable: #68756e;
  --rr-color-forest: #225c51;
  --rr-color-forest-hover: #19473e;
  --rr-color-forest-soft: #e3f1ed;
  --rr-color-gold: #b88943;
  --rr-color-heart: #e11d48;
  --rr-color-heart-bg: #fff1f2;
  --rr-color-line: #dbe2d9;

  /* Seven reading-range colors (aligned with Library & Catalog) */
  --rr-range-Red: #dc2626;
  --rr-range-Green: #15803d;
  --rr-range-Blue: #1d4ed8;
  --rr-range-Lime: #4d7c0f;
  --rr-range-Purple: #6d28d9;
  --rr-range-Yellow: #a16207;
  --rr-range-Orange: #c2410c;

  /* Tier 2: Typography */
  --rr-font-serif: Georgia, "Fraunces", "Iowan Old Style", serif;
  --rr-font-sans: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* Tier 3: Layout & shape */
  --rr-max-inline-page: 1200px;
  --rr-max-inline-header: 1240px;
  --rr-gutter-inline: 24px;
  --rr-radius-sm: 8px;
  --rr-radius-md: 14px;
  --rr-radius-lg: 20px;
  --rr-focus-width: 3px;
  --rr-focus-offset: 3px;
}

/* ---------- header and First Steps sub-bar (site-shell.css @layer header) ---------- */
.rr-global-header {
  background: var(--rr-color-header-bg);
  border-block-end: 1px solid var(--rr-color-line);
  color: var(--rr-color-ink);
  font-family: var(--rr-font-sans);
}

.rr-global-inner {
  max-inline-size: var(--rr-max-inline-header);
  margin-inline: auto;
  padding-block: 11px;
  padding-inline: clamp(16px, 2.4vw, 24px);
  display: flex;
  align-items: center;
  gap: clamp(14px, 2vw, 28px);
  flex-wrap: nowrap;
}

.rr-global-brand {
  font: 700 clamp(1.2rem, 1.9vw, 1.52rem)/1.2 var(--rr-font-serif);
  letter-spacing: -0.03em;
  color: var(--rr-color-forest);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.rr-global-menu {
  display: flex;
  align-items: center;
  gap: clamp(10px, 1.5vw, 20px);
  flex: 1 1 auto;
  min-inline-size: 0;
  flex-wrap: nowrap;
  font-size: clamp(0.88rem, 1.08vw, 0.96rem);
  line-height: 1.35;
  font-weight: 700;
}

.rr-global-group {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: clamp(10px, 1.6vw, 20px);
}

.rr-global-adults {
  margin-inline-start: auto;
  border-inline-start: 1px solid var(--rr-color-line);
  padding-inline-start: clamp(10px, 1.5vw, 18px);
  gap: 8px;
  flex-shrink: 0;
}

.rr-kid-icon,
.rr-label-short {
  display: none;
}

.rr-global-menu a {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding-block: 6px;
  white-space: nowrap;
  text-decoration: none;
  color: var(--rr-color-ink-nav);
  border-block-end: 2px solid transparent;
}

.rr-global-menu a:hover {
  color: var(--rr-color-forest);
}

.rr-global-menu a[aria-current="page"],
.rr-global-menu a[aria-current="true"] {
  color: var(--rr-color-forest);
  border-block-end-color: currentColor;
}

.rr-global-menu a.rr-adult-link {
  font-size: clamp(0.8rem, 0.98vw, 0.86rem);
  font-weight: 650;
  color: var(--rr-color-muted);
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--rr-color-wash);
  border-block-end: 0;
}

.rr-global-menu a.rr-adult-link:hover,
.rr-global-menu a.rr-adult-link[aria-current="page"] {
  color: var(--rr-color-forest);
  background: var(--rr-color-forest-soft);
}

.rr-global-menu a.rr-studio-nav-btn {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--rr-color-forest);
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--rr-color-line);
  background: var(--rr-color-surface);
  border-block-end: 1px solid var(--rr-color-line);
}

.rr-global-menu a.rr-studio-nav-btn:hover {
  background: var(--rr-color-forest-soft);
  border-color: var(--rr-color-forest);
}

.rr-nav-icon {
  flex-shrink: 0;
}

.rr-nav-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-inline-size: 1.35rem;
  block-size: 1.35rem;
  padding-inline: 5px;
  border-radius: 999px;
  background: var(--rr-color-forest);
  color: #fff;
  font-size: 0.74rem;
  font-weight: 800;
}

.rr-section-nav {
  background: var(--rr-color-wash);
  border-block-end: 1px solid var(--rr-color-line);
  padding-block: 10px;
  padding-inline: var(--rr-gutter-inline);
  display: flex;
  gap: 10px 20px;
  justify-content: center;
  flex-wrap: wrap;
  font: 700 0.9rem/1.5 var(--rr-font-sans);
}

.rr-section-nav a {
  color: var(--rr-color-forest);
  text-decoration: none;
}

.rr-section-nav a[aria-current] {
  text-decoration: underline;
  text-underline-offset: 5px;
}

@media (max-width: 960px) {
  .rr-global-adults {
    border-inline-start: 0;
    padding-inline-start: 0;
  }
  .rr-studio-nav-label {
    display: none;
  }
  .rr-global-menu a.rr-studio-nav-btn {
    padding: 6px 8px;
  }
}

@media (max-width: 800px) {
  .rr-global-inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand adults"
      "readers readers";
    align-items: center;
    column-gap: 8px;
    row-gap: 8px;
    padding: 10px 12px;
  }
  .rr-global-brand {
    grid-area: brand;
    font-size: clamp(1.12rem, 4.4vw, 1.32rem);
    min-inline-size: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .rr-global-menu {
    display: contents;
  }
  .rr-global-adults {
    grid-area: adults;
    margin-inline-start: 0;
    justify-self: end;
    gap: 6px;
  }
  .rr-global-menu a.rr-adult-link {
    font-size: 0.78rem;
    padding: 6px 10px;
    min-block-size: 34px;
  }
  .rr-global-readers {
    grid-area: readers;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
    background: var(--rr-color-wash);
    padding: 4px;
    border-radius: 14px;
    border: 1px solid var(--rr-color-line);
  }
  .rr-kid-icon {
    display: block;
    inline-size: 18px;
    block-size: 18px;
    flex-shrink: 0;
  }
  .rr-label-long {
    display: none;
  }
  .rr-label-short {
    display: inline;
  }
  .rr-global-readers a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-block-size: 46px;
    padding: 5px 4px;
    border-radius: 10px;
    border-block-end: 0;
    font-size: clamp(0.72rem, 2.7vw, 0.82rem);
    font-weight: 750;
    line-height: 1.15;
    text-align: center;
    white-space: normal;
    text-wrap: balance;
  }
  .rr-global-readers a[aria-current="page"],
  .rr-global-readers a[aria-current="true"] {
    background: var(--rr-color-surface);
    color: var(--rr-color-forest);
    box-shadow: 0 1px 4px rgba(30, 41, 39, 0.1), 0 0 0 1px rgba(31, 92, 81, 0.16);
  }
  .rr-global-readers .rr-nav-count {
    position: absolute;
    inset-block-start: 3px;
    inset-inline-end: 5px;
    min-inline-size: 1.15rem;
    block-size: 1.15rem;
    padding-inline: 4px;
    font-size: 0.66rem;
  }
  .rr-section-nav {
    padding: 9px 14px;
    gap: 6px 16px;
    font-size: 0.85rem;
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .rr-section-nav::-webkit-scrollbar {
    display: none;
  }
  .rr-section-nav a {
    white-space: nowrap;
    flex-shrink: 0;
  }
}

@media (min-width: 560px) and (max-width: 800px) {
  .rr-global-readers a {
    flex-direction: row;
    gap: 6px;
    min-block-size: 42px;
    font-size: 0.85rem;
  }
  .rr-global-readers .rr-nav-count {
    position: static;
  }
}

@media (max-width: 420px) {
  .rr-global-adults:has([data-studio-only]:not([hidden])) .rr-adult-extra {
    display: none;
  }
}

@media (forced-colors: active) {
  .rr-global-menu a[aria-current] {
    border-block-end-color: LinkText;
    outline: 2px solid Highlight;
  }
}

/* ---------- quiet footer and Studio lock (site-shell.css @layer footer) ---------- */
.rr-global-footer {
  margin-block-start: auto;
  background: var(--rr-color-header-bg);
  border-block-start: 1px solid var(--rr-color-line);
  padding-block: 20px;
  color: var(--rr-color-muted);
  font-size: 0.85rem;
}

.rr-footer-inner {
  max-inline-size: var(--rr-max-inline-header);
  margin-inline: auto;
  padding-inline: var(--rr-gutter-inline);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 24px;
}

.rr-footer-brand strong {
  font-family: var(--rr-font-serif);
  color: var(--rr-color-ink);
}

.rr-footer-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 16px;
}

.rr-footer-label {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.75rem;
}

.rr-footer-links a {
  color: var(--rr-color-muted);
  text-decoration: none;
}

.rr-footer-links a:hover {
  color: var(--rr-color-forest);
  text-decoration: underline;
}

.rr-admin-lock-btn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--rr-color-muted);
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.8rem;
  line-height: 1.3;
  cursor: pointer;
  opacity: 0.72;
}

.rr-admin-lock-btn:hover {
  opacity: 1;
  border-color: var(--rr-color-line);
  background: var(--rr-color-wash);
  color: var(--rr-color-ink);
}

/* ---------- Studio unlock dialog (site/index.html) ---------- */
dialog.rr-studio-dialog {
  border: 1px solid var(--rr-color-line);
  border-radius: 16px;
  padding: 22px 24px;
  background: var(--rr-color-surface);
  color: var(--rr-color-ink);
  max-inline-size: min(360px, calc(100vw - 32px));
  inline-size: 100%;
  box-shadow: 0 18px 44px rgba(20, 30, 28, 0.22);
}
dialog.rr-studio-dialog:modal {
  overscroll-behavior: contain;
}
dialog.rr-studio-dialog::backdrop {
  background: rgba(20, 30, 28, 0.42);
  overflow: hidden;
  overscroll-behavior: contain;
}
.rr-studio-dialog h1 {
  margin: 0 0 6px;
  font: 700 1.2rem/1.25 var(--rr-font-serif);
}
.rr-studio-dialog p {
  margin: 0 0 12px;
  font-size: 0.88rem;
  color: var(--rr-color-muted);
}
.rr-studio-input {
  inline-size: 100%;
  padding: 9px 12px;
  border: 1px solid var(--rr-color-line);
  border-radius: 8px;
  background: var(--rr-color-paper);
  color: var(--rr-color-ink);
  font-size: 0.95rem;
}
.rr-studio-error {
  min-block-size: 1.25em;
  margin-block: 6px 10px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #b91c1c;
}
.rr-studio-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.rr-studio-actions button {
  min-block-size: 40px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 2px solid var(--rr-color-forest);
  font: 700 0.92rem/1.2 var(--rr-font-sans);
  cursor: pointer;
}
.rr-studio-actions .btn-primary { background: var(--rr-color-forest); color: #fff; }
.rr-studio-actions .btn-secondary { background: var(--rr-color-surface); color: var(--rr-color-forest); }

/* Studio-only controls stay hidden until unlocked, whatever the page's own display rules say. */
[data-studio-only][hidden] { display: none !important; }
