/* Sitewide base for every page (linked root-relative as /assets/site.css?v=<hash>; re-stamp with
   scripts/stamp_asset_versions.py after any change, because Cloudflare caches CSS for 4 hours).
   One place for rules that used to be copied into each page's inline styles. Per-instance size
   (padding, radius, font-size, weight) stays inline on the element; the look and the hover live here. */

/* ---- Buttons ---- */
.btn-primary, .btn-sage, .btn-ghost, .btn-ghost-dark { font-family: 'Inter Tight', sans-serif; text-decoration: none; cursor: pointer; }
.btn-primary { background: #9A4E36; color: #F7F4ED; border: none; transition: background-color .18s; }
.btn-sage { background: #5E6E55; color: #F4F1EA; border: none; transition: background-color .18s; }
.btn-ghost { background: transparent; color: #25342A; border: 1px solid #C6BEAC; transition: border-color .18s, color .18s; }
.btn-ghost-dark { background: transparent; color: #F4F1EA; border: 1px solid rgba(244,241,234,.32); transition: border-color .18s, color .18s; }

/* Hover only on devices that hover, so a tap never leaves a stuck hover colour. */
@media (hover: hover) {
  .btn-primary:hover { background: #833F2A; }
  .btn-sage:hover { background: #4D5A44; }
  .btn-ghost:hover { border-color: #5E6E55 !important; color: #5E6E55; }
  .btn-ghost-dark:hover { border-color: #9CAB90; color: #9CAB90; }
}

/* ---- Hover on cards, rows and text links (moved out of style-hover attributes and JS mouseenter/mouseleave) ----
   !important only where the element still carries the same property inline. */
@media (hover: hover) {
  /* Desktop nav item: leading dot fades in, label turns terracotta. */
  .navlink:hover { color: #9A4E36 !important; }
  .navlink:hover .navdot { opacity: 1 !important; transform: scale(1) !important; }
  /* Text link whose underline appears on hover. */
  .bio-link:hover, .email-link:hover { border-bottom-color: #B26248 !important; }
  /* Dark-green "free tools and essays" rows on the home page. */
  .tool-row:hover { background: rgba(244,241,234,.05) !important; padding-left: 14px !important; }
  /* Scholarship and profile rows on /about. */
  .lk-row:hover { background: rgba(94,110,85,.06) !important; padding-left: 14px !important; }
  /* Contact route cards (dark) and connect cards (light). */
  .route-card:hover { border-color: #D98C70 !important; transform: translateY(-2px); box-shadow: 0 16px 36px rgba(13,22,16,.34); }
  .connect-card:hover { border-color: #9A4E36 !important; transform: translateY(-2px); box-shadow: 0 12px 28px rgba(40,55,40,.10); }
  .connect-card:hover .cc-arrow { transform: translateX(4px) !important; }
  /* Library cards that link somewhere (cards without .lib-action stay still). */
  .lib-card:has(.lib-action):hover { border-color: #9A4E36 !important; transform: translateY(-3px); box-shadow: 0 14px 32px rgba(40,55,40,.10); }
}

/* ---- Keyboard focus: one visible ring on every link, button and form control ---- */
a:focus-visible, button:focus-visible, summary:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, [role="button"]:focus-visible, [tabindex]:not([tabindex="-1"]):focus-visible {
  outline: 2px solid #9A4E36; outline-offset: 2px;
}
/* The terracotta ring would vanish on the forest-green sections. */
[data-green-fade] a:focus-visible, [data-green-fade] button:focus-visible, [data-green-fade] summary:focus-visible,
[data-green-fade] [role="button"]:focus-visible { outline-color: #F4F1EA; }
/* Keyboard focus mirrors the desktop nav hover. */
a:focus-visible .navlink { color: #9A4E36 !important; }
a:focus-visible .navlink .navdot { opacity: 1 !important; transform: scale(1) !important; }

/* ---- Page scroll: clip, not hidden, so html/body are not a trapped scroll container ----
   (the pages set overflow-x: clip on html, body). Safari before 16 has no clip: keep the old hidden there. */
@supports not (overflow-x: clip) {
  html, body { overflow-x: hidden; }
}

/* ---- Forest-green sections ([data-green-fade]) ----
   Green by default in CSS, so slow networks, failed scripts and printouts never show cream text on cream.
   The scroll-fade is a cream veil (an inset shadow, so background-color stays green) that the page script
   adds as .gf-pre to sections still below the fold and removes as they scroll into view. */
[data-green-fade] {
  background-color: #243029;
  box-shadow: inset 0 0 0 100vmax rgba(244,241,234,0);
  transition: box-shadow 1s cubic-bezier(.22,.61,.36,1);
}
[data-green-fade].gf-pre { box-shadow: inset 0 0 0 100vmax rgba(244,241,234,1); }

/* ---- Print: everything that fades or reveals on scroll prints visible ---- */
@media print {
  [data-reveal], [data-reveal-seq] > * { opacity: 1 !important; transform: none !important; }
  [data-green-fade] { background-color: #243029 !important; box-shadow: none !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---- Skip link: first focusable element on every page, visible only when it has keyboard focus ---- */
.skip-link {
  position: absolute; left: 0; top: 0; z-index: 1000;
  width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.skip-link:focus-visible {
  width: auto; height: auto; overflow: visible; clip: auto; clip-path: none; white-space: normal;
  left: 12px; top: 12px; padding: 12px 20px; border-radius: 8px;
  background: #25342A; color: #F4F1EA; font: 600 15px/1.2 'Inter Tight', sans-serif; text-decoration: none;
  outline: 2px solid #F4F1EA; outline-offset: -5px; box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
/* <main id="main" tabindex="-1"> receives focus from the skip link; it needs no ring of its own. */
main:focus { outline: none; }
