/* 2025-2026.msbrandolini.com — components.css
 *
 * Component-level styling. Design tokens and global preferences are defined
 * in site.css and must be loaded FIRST; this file only consumes them.
 *
 * Sections: page header + breadcrumb, page shell, sections, terms (tooltip +
 * short + long), embedded reading, embedded diagram, prose links, site
 * footer, skip-to-content link, toggle widget, translate menu.
 */

/* --- page header + breadcrumb --- */

.page-header {
  max-width: 920px;
  margin: 0 auto;
  padding: 32px 28px 8px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.mark {
  font-family: 'Fraunces', serif;
  font-variation-settings: "opsz" 144, "SOFT" 80;
  font-style: italic;
  font-weight: 500;
  font-size: 18px;
  color: var(--accent-deep);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.mark:hover { color: var(--accent); }

.breadcrumb {
  font-size: 13px;
  color: var(--ink-quiet);
  letter-spacing: 0.02em;
  display: flex;
  gap: 8px;
  align-items: baseline;
  flex-wrap: wrap;
}
.breadcrumb a { color: var(--ink-dim); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent-deep); }
.breadcrumb .sep { color: var(--ink-quiet); opacity: 0.5; }
.breadcrumb .current { color: var(--ink); }



/* --- page shell --- */

main {
  max-width: 920px;
  margin: 0 auto;
  padding: 40px 28px 16px;
}

.page-title { margin-bottom: 56px; }
.page-title .eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-quiet);
  margin-bottom: 16px;
}
.page-title h1 {
  font-family: 'Fraunces', serif;
  font-variation-settings: "opsz" 144, "SOFT" 50;
  font-weight: 380;
  font-size: clamp(40px, 6vw, 60px);
  line-height: 1.05;
  letter-spacing: -0.025em;
  margin-bottom: 20px;
  color: var(--ink);
}
.page-title .lede {
  font-family: 'Fraunces', serif;
  font-variation-settings: "opsz" 48, "SOFT" 40;
  font-weight: 350;
  font-size: 21px;
  line-height: 1.5;
  color: var(--ink);
  max-width: var(--reading-width);
}



/* --- sections --- */

.page-section {
  max-width: var(--reading-width);
  margin: 0 0 56px;
}
.page-section h2 {
  font-family: 'Fraunces', serif;
  font-variation-settings: "opsz" 48, "SOFT" 40;
  font-weight: 420;
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: -0.015em;
  margin-bottom: 16px;
  color: var(--ink);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule);
}
.page-section p { margin-bottom: 16px; }
.page-section p:last-child { margin-bottom: 0; }

.term-list {
  list-style: none;
  padding: 0;
  margin: 12px 0;
}
.term-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
}
.term-list li:last-child { border-bottom: none; }



/* --- terms: tooltip (default) --- */
/* Screen-reader-accessible tooltip pattern: the tooltip text lives in a real
   DOM element (.term-tip) pointed to by aria-describedby. Visually hidden by
   default via the sr-only technique; CSS un-hides it on hover / focus so
   sighted users see the standard tooltip affordance. */

.term {
  border-bottom: 1px dashed var(--accent-deep);
  cursor: help;
  position: relative;
  color: var(--ink);
  font-weight: 600;
  outline: none;
}
.term:hover, .term:focus, .term:focus-visible {
  color: var(--accent-deep);
  background: var(--accent-soft);
  border-bottom-style: solid;
}

/* Default state: visually hidden, still in the accessibility tree for
   screen readers via aria-describedby. */
.term-tip {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;

  /* Visual styling (activates when un-hidden below). */
  background: var(--ink);
  color: var(--bg);
  font-family: 'Atkinson Hyperlegible', sans-serif;
  font-weight: 400;
  font-size: 14px;
  line-height: 1.45;
  border-radius: 6px;
  text-align: left;
  box-shadow: 0 8px 24px rgba(43, 37, 24, 0.22);
  z-index: 10;
  transition: opacity 0.18s ease;
}

/* Shown state: positioned tooltip above the term, pointer-unreachable so it
   doesn't interfere with hover targeting. */
.term:hover .term-tip,
.term:focus .term-tip,
.term:focus-visible .term-tip,
.term:focus-within .term-tip {
  position: absolute;
  width: auto;
  height: auto;
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
  padding: 10px 14px;
  min-width: 200px;
  max-width: 280px;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%);
  pointer-events: none;
}

/* Arrow below tooltip */
.term:hover::after,
.term:focus::after,
.term:focus-visible::after,
.term:focus-within::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: calc(100% + 4px);
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--ink);
  z-index: 10;
  pointer-events: none;
}

@media (max-width: 600px) {
  .term:hover .term-tip,
  .term:focus .term-tip,
  .term:focus-visible .term-tip,
  .term:focus-within .term-tip {
    max-width: 240px;
    font-size: 13px;
  }
}



/* --- terms: inline short expansion --- */

.term-short {
  display: inline;
  padding: 2px 8px;
  margin: 0 2px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 4px 4px 0;
  font-style: italic;
}



/* --- terms: block long expansion --- */

.term-long {
  margin: 20px 0;
  padding: 20px 24px;
  background: var(--bg-tint);
  border-left: 4px solid var(--accent);
  border-radius: 0 6px 6px 0;
}
.term-long p { margin-bottom: 12px; }
.term-long p:last-child { margin-bottom: 0; }
.term-long::before {
  content: attr(data-term);
  display: block;
  font-family: 'Atkinson Hyperlegible', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent-deep);
  margin-bottom: 12px;
}



/* --- embedded reading --- */

.reading {
  margin: 24px 0;
  padding: 32px 36px;
  background: var(--bg-tint);
  border-radius: 8px;
  border: 1px solid var(--rule);
}
.reading-header h2 {
  font-family: 'Fraunces', serif;
  font-variation-settings: "opsz" 72, "SOFT" 40;
  font-weight: 420;
  font-size: 26px;
  margin-bottom: 6px;
  padding-bottom: 0;
  border-bottom: none;
  color: var(--ink);
}
.reading-header::after {
  content: 'reading';
  display: block;
  font-family: 'Atkinson Hyperlegible', sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-quiet);
  margin-bottom: 20px;
}
.reading h2 {
  font-family: 'Fraunces', serif;
  font-variation-settings: "opsz" 48, "SOFT" 40;
  font-weight: 420;
  font-size: 22px;
  margin-top: 24px;
  margin-bottom: 12px;
  color: var(--ink);
}
.reading > .reading-header + h2,
.reading > .reading-header ~ h2:first-of-type {
  margin-top: 4px;
}
.reading p { margin-bottom: 14px; line-height: 1.7; }
.reading p:last-child { margin-bottom: 0; }



/* --- embedded diagram --- */

.diagram {
  margin: 24px 0;
  padding: 28px 24px 20px;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 8px;
  color: var(--ink);
  text-align: center;
}
.diagram svg {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  height: auto;
  color: var(--ink-dim);
}
.diagram figcaption {
  margin-top: 16px;
  font-family: 'Fraunces', serif;
  font-variation-settings: "opsz" 24, "SOFT" 60;
  font-style: italic;
  font-size: 15px;
  color: var(--ink-quiet);
}



/* --- links in prose --- */

main a:not(.mark) {
  color: var(--accent-deep);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 3px;
}
main a:not(.mark):hover {
  color: var(--accent);
  text-decoration-color: var(--accent-deep);
}



/* --- footer --- */

.site-footer {
  max-width: 920px;
  margin: 64px auto 0;
  padding: 24px 28px 16px;
  border-top: 1px solid var(--rule);
  font-size: 13px;
  color: var(--ink-quiet);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.site-footer .quiet { color: var(--ink-quiet); }
.site-footer a {
  color: var(--ink-dim);
  text-decoration: none;
}
.site-footer a:hover { color: var(--accent-deep); }



  left: 0;
  background: var(--ink);
  color: var(--bg);
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  border-radius: 0 0 6px 0;
  z-index: 100;
  transition: top 0.15s ease;
}
.skip-link:focus, .skip-link:focus-visible {
  top: 0;
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}



/* --- preferences UI wrapper --- */
/* .controls holds .toggles and .translate side-by-side at the right of the
   page header. Wraps to a new row on narrow viewports. */

.controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

@media (max-width: 600px) {
  .page-header {
    align-items: flex-start;
  }
  .controls {
    width: 100%;
    justify-content: flex-end;
    margin-top: 8px;
  }
}

/* --- toggle widget --- */
/* Sits in the page header, right-aligned. Three cycle-buttons: scheme, size, font.
   Each click advances to the next value and persists to localStorage via
   /static/toggles.js. */

.toggles {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-shrink: 0;
}
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 5px;
  font-family: 'Atkinson Hyperlegible', sans-serif;
  font-size: 12px;
  color: var(--ink-dim);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  min-height: 32px;
}
.toggle:hover, .toggle:focus-visible {
  background: var(--bg-tint);
  border-color: var(--rule-strong);
  color: var(--ink);
  outline: none;
}
.toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.toggle .toggle-icon {
  font-size: 14px;
  line-height: 1;
  font-weight: 700;
  color: var(--accent-deep);
}
.toggle .toggle-label {
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--ink-quiet);
  white-space: nowrap;
}
.toggle:hover .toggle-label { color: var(--ink-dim); }



/* --- translate menu --- */

.translate {
  position: relative;
  font-family: 'Atkinson Hyperlegible', sans-serif;
  font-size: 13px;
}
.translate > summary {
  list-style: none;
  padding: 6px 12px;
  border: 1px solid var(--rule);
  border-radius: 5px;
  color: var(--ink-dim);
  cursor: pointer;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.translate > summary::-webkit-details-marker { display: none; }
.translate > summary::before {
  content: '🌐';
  font-size: 13px;
}
.translate > summary:hover, .translate[open] > summary {
  background: var(--bg-tint);
  border-color: var(--rule-strong);
  color: var(--ink);
}
.translate > summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.translate nav {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  background: var(--bg);
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  padding: 6px;
  box-shadow: 0 8px 24px rgba(43, 37, 24, 0.18);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.translate nav a {
  padding: 8px 12px;
  color: var(--ink-dim);
  text-decoration: none;
  border-radius: 4px;
  font-size: 14px;
  transition: background 0.12s, color 0.12s;
  display: block;
}
.translate nav a:hover, .translate nav a:focus-visible {
  background: var(--accent-soft);
  color: var(--ink);
  outline: none;
}

/* Narrow viewports: toggle row stacks below breadcrumb if header wraps. */
@media (max-width: 600px) {
  .toggles, .translate { font-size: 11px; }
  .toggle { padding: 5px 8px; min-height: 30px; }
  .translate > summary { padding: 5px 10px; min-height: 30px; }
}
