/*
Theme Name: Hiking For Beginners
Description: Field-manual theme — warm paper, forest green, trail orange. Built to the bundle's design system.
Version: 1.0
Requires at least: 6.0
Tested up to: 7.1
Requires PHP: 8.0
Text Domain: hfb
*/

/* ===========================================================================
   Design tokens — verbatim from the handoff README.
   ========================================================================= */
:root {
  --paper:       #F5EFE2;
  --paper-card:  #FBF7EE;
  --panel-tan:   #EFE7D7;
  --ink:         #1C1A17;
  --forest:      #33463A;
  --orange:      #E1571F;
  --gold:        #C8B088;
  --slate:       #6E7377;
  --slate-text:  #565B5F;
  --warm-gray:   #9a9382;

  --hairline: rgba(28,26,23,.14);

  --sans:  'Libre Franklin', system-ui, -apple-system, sans-serif;
  --serif: 'Spectral', Georgia, serif;
  --mono:  'IBM Plex Mono', ui-monospace, monospace;

  --shell:   1200px;
  --measure: 70ch;
  --sidebar: 292px;

  --r-card: 12px;
  --r-btn:  8px;
  --r-call: 5px;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--forest); text-decoration: none; }
a:hover { color: var(--orange); }

h1, h2, h3, h4 { margin: 0; font-family: var(--sans); font-weight: 700; line-height: 1.15; }

:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }

.hfb-skip { position: absolute; left: -9999px; background: var(--forest); color: var(--paper); padding: 10px 16px; z-index: 100; }
.hfb-skip:focus { left: 12px; top: 12px; }

.hfb-shell { max-width: var(--shell); margin: 0 auto; padding: 0 clamp(16px, 4vw, 32px); }

/* Kicker — mono, uppercase, trail orange */
.hfb-kicker {
  font-family: var(--mono); font-size: .74rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: .13em; color: var(--orange); margin: 0;
}
.hfb-kicker--muted { color: var(--warm-gray); }

/* Diamond brand mark — CSS only, no raster asset per the spec */
.hfb-diamond {
  display: inline-block; width: 13px; height: 13px;
  border: 2.5px solid var(--forest); transform: rotate(45deg);
  margin-right: 11px; flex-shrink: 0;
}
.hfb-footer .hfb-diamond { border-color: var(--gold); }

/* ===========================================================================
   Buttons
   ========================================================================= */
.hfb-btn {
  display: inline-block; font-family: var(--sans); font-size: 15px; font-weight: 600;
  padding: 13px 22px; border-radius: var(--r-btn); border: 1.5px solid transparent; cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.hfb-btn--primary { background: var(--orange); color: #fff; }
.hfb-btn--primary:hover { background: #c8481400; background: #C84A16; color: #fff; }
.hfb-btn--outline { border-color: var(--hairline); color: var(--ink); }
.hfb-btn--outline:hover { border-color: var(--forest); color: var(--forest); }

/* ===========================================================================
   Header
   ========================================================================= */
.hfb-header {
  position: sticky; top: 0; z-index: 40; height: 64px;
  background: rgba(245,239,226,.86); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--hairline);
}
.hfb-header__inner {
  max-width: var(--shell); margin: 0 auto; height: 64px;
  padding: 0 clamp(16px, 4vw, 32px); display: flex; align-items: center; gap: 24px;
}
.hfb-brand { display: flex; align-items: center; font-family: var(--sans); font-weight: 800; font-size: 17px; letter-spacing: -.01em; color: var(--ink); }
.hfb-brand:hover { color: var(--forest); }

.hfb-nav { margin-left: auto; display: flex; align-items: center; gap: 22px; }
.hfb-nav a { font-size: 14.5px; font-weight: 500; color: var(--slate-text); }
.hfb-nav a:hover { color: var(--forest); }
.hfb-nav__toggle { display: none; background: none; border: 0; font-size: 21px; color: var(--ink); cursor: pointer; }

@media (max-width: 900px) {
  .hfb-nav__toggle { display: block; margin-left: auto; }
  .hfb-nav {
    display: none; position: absolute; top: 64px; left: 0; right: 0; flex-direction: column;
    align-items: stretch; gap: 0; background: var(--paper-card);
    border-bottom: 1px solid var(--hairline); padding: 8px 0;
  }
  .hfb-nav.is-open { display: flex; }
  .hfb-nav a { padding: 13px clamp(16px, 4vw, 32px); }
  .hfb-nav .hfb-btn { margin: 8px clamp(16px, 4vw, 32px); text-align: center; }
}

/* ===========================================================================
   Footer — dark ink ground, gold mark
   ========================================================================= */
.hfb-footer { background: var(--ink); color: var(--panel-tan); margin-top: 80px; padding: 48px 0; font-size: 14px; }
.hfb-footer__inner { max-width: var(--shell); margin: 0 auto; padding: 0 clamp(16px, 4vw, 32px); display: flex; flex-wrap: wrap; gap: 22px; align-items: center; }
.hfb-footer a { color: var(--panel-tan); }
.hfb-footer a:hover { color: var(--gold); }
.hfb-footer nav { display: flex; gap: 22px; margin-left: auto; flex-wrap: wrap; }
.hfb-footer__brand { display: flex; align-items: center; font-weight: 800; color: var(--paper); }

/* ===========================================================================
   Home
   ========================================================================= */
.hfb-hero { display: grid; grid-template-columns: 1.05fr .95fr; gap: clamp(28px,5vw,60px); align-items: center; padding: clamp(40px,6vw,84px) 0 clamp(28px,4vw,56px); }
@media (max-width: 900px) { .hfb-hero { grid-template-columns: 1fr; } }
.hfb-hero h1 { font-size: clamp(2rem, 4.5vw, 3rem); font-weight: 800; line-height: 1.04; letter-spacing: -.025em; margin: 16px 0 0; }
.hfb-hero__lede { font-family: var(--serif); font-size: 1.15rem; line-height: 1.7; color: var(--slate-text); max-width: 52ch; margin: 20px 0 0; }
.hfb-hero__cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }
.hfb-ticks { display: flex; flex-wrap: wrap; gap: 20px; margin-top: 26px; font-family: var(--mono); font-size: .74rem; text-transform: uppercase; letter-spacing: .1em; color: var(--warm-gray); }
.hfb-ticks span::before { content: "✓ "; color: var(--forest); }

.hfb-band { background: var(--forest); color: var(--paper); padding: clamp(40px,5.5vw,76px) 0; }
.hfb-band h2 { font-size: clamp(1.6rem,3vw,2.3rem); font-weight: 800; letter-spacing: -.02em; color: var(--paper); }
.hfb-band p { color: rgba(245,239,226,.8); max-width: 54ch; }
.hfb-band .hfb-kicker { color: var(--gold); }

.hfb-parts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 900px) { .hfb-parts { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .hfb-parts { grid-template-columns: 1fr; } }
.hfb-part { background: var(--paper-card); border: 1px solid var(--hairline); border-radius: var(--r-card); padding: 22px 20px; color: inherit; }
.hfb-part:hover { border-color: var(--gold); }
.hfb-part h3 { font-size: 1.05rem; font-weight: 700; margin: 9px 0 6px; color: var(--forest); }
.hfb-part p { font-size: 14px; color: var(--slate-text); margin: 0; }

/* The cards are links and must read as links. Without an explicit affordance
   they look like inert panels, and people do not click inert panels. */
.hfb-part { display: flex; flex-direction: column; }
.hfb-part h3 { text-decoration: underline; text-decoration-color: rgba(51,70,58,.28); text-underline-offset: 3px; }
.hfb-part:hover h3 { text-decoration-color: var(--orange); color: var(--orange); }
.hfb-part__go {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  margin-top: auto; padding-top: 14px;
  font-family: var(--mono); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase;
}
.hfb-part__go > span:first-child { color: var(--orange); }
.hfb-part__go > span:first-child::after { content: " →"; }
.hfb-part:hover .hfb-part__go > span:first-child::after { content: " →"; padding-left: 3px; }
.hfb-part__count { color: var(--warm-gray); }

/* ===========================================================================
   Browse
   ========================================================================= */
.hfb-browse__part { padding: 30px 0; border-top: 1px solid var(--hairline); display: grid; grid-template-columns: var(--sidebar) 1fr; gap: 32px; }
@media (max-width: 900px) { .hfb-browse__part { grid-template-columns: 1fr; gap: 14px; } }
.hfb-browse__label h2 { font-size: 1.25rem; font-weight: 700; color: var(--forest); margin-top: 8px; }
.hfb-browse__row { display: flex; align-items: baseline; gap: 16px; padding: 12px 14px; border-bottom: 1px solid var(--hairline); color: var(--ink); border-radius: 6px; }
.hfb-browse__row:hover { background: var(--panel-tan); }
.hfb-browse__row:hover .hfb-browse__arrow { opacity: 1; transform: translateX(3px); }
.hfb-browse__n { font-family: var(--mono); font-size: 12px; color: var(--warm-gray); min-width: 26px; }
.hfb-browse__t { font-weight: 600; font-size: 15.5px; }
.hfb-browse__arrow { margin-left: auto; color: var(--orange); opacity: 0; transition: all .15s ease; }

/* ===========================================================================
   Reader
   ========================================================================= */
.hfb-reader { display: grid; grid-template-columns: var(--sidebar) 1fr; gap: clamp(24px,4vw,52px); max-width: var(--shell); margin: 0 auto; padding: 0 clamp(16px,4vw,32px); align-items: start; }
@media (max-width: 900px) { .hfb-reader { grid-template-columns: 1fr; } }

.hfb-toc { position: sticky; top: 84px; max-height: calc(100vh - 108px); overflow-y: auto; padding: 26px 16px 40px 0; border-right: 1px solid var(--hairline); }
@media (max-width: 900px) {
  .hfb-toc { position: static; max-height: none; border-right: 0; padding-right: 0; border-bottom: 1px solid var(--hairline); }
  .hfb-toc__list { display: none; }
  .hfb-toc.is-open .hfb-toc__list { display: block; }
  .hfb-toc__toggle { display: flex; }
}
.hfb-toc__toggle { display: none; width: 100%; align-items: center; justify-content: space-between; background: none; border: 0; padding: 15px 0; cursor: pointer; font-family: var(--mono); font-size: .74rem; text-transform: uppercase; letter-spacing: .13em; color: var(--ink); }
.hfb-toc__group { font-family: var(--mono); font-size: .68rem; text-transform: uppercase; letter-spacing: .13em; color: var(--warm-gray); margin: 22px 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--hairline); }
.hfb-toc__group:first-child { margin-top: 0; }
.hfb-toc a { display: flex; gap: 10px; align-items: baseline; padding: 7px 10px; font-size: 14px; color: var(--slate-text); border-left: 2px solid transparent; border-radius: 0 5px 5px 0; }
.hfb-toc a:hover { background: var(--panel-tan); color: var(--ink); }
.hfb-toc a.is-active { border-left-color: var(--orange); background: var(--panel-tan); color: var(--ink); font-weight: 600; }
.hfb-toc a.is-active .hfb-toc__n { color: var(--orange); }
.hfb-toc__n { font-family: var(--mono); font-size: 11.5px; color: var(--warm-gray); min-width: 20px; }

.hfb-chapter { max-width: 100%; padding: 32px 0 40px; }
.hfb-chapter__head { border-bottom: 1px solid var(--hairline); padding-bottom: 24px; margin-bottom: 32px; }
.hfb-chapter__head h1 { font-size: clamp(2rem, 4.5vw, 3rem); font-weight: 800; line-height: 1.04; letter-spacing: -.025em; margin: 12px 0 0; }
.hfb-chapter__deck { font-family: var(--serif); font-style: italic; font-size: 1.15rem; color: var(--slate-text); margin: 12px 0 0; }
.hfb-chapter__meta { font-family: var(--mono); font-size: .74rem; text-transform: uppercase; letter-spacing: .1em; color: var(--warm-gray); margin-top: 14px; }

/* ---- Prose ---- */
.hfb-prose { font-family: var(--serif); font-size: 1.15rem; line-height: 1.72; color: var(--ink); max-width: var(--measure); }
.hfb-prose > p:first-of-type { font-size: 1.28rem; line-height: 1.62; color: var(--slate-text); }
.hfb-prose p { margin: 0 0 1.15em; }
.hfb-prose h2 {
  font-family: var(--sans); font-size: 1.55rem; font-weight: 600; color: var(--forest);
  margin: 2.2em 0 .7em; padding-top: .8em; border-top: 1px solid var(--hairline);
}
.hfb-prose h3 { font-family: var(--sans); font-size: 1.15rem; font-weight: 600; margin: 1.7em 0 .5em; }
.hfb-prose h4 { font-family: var(--sans); font-size: 1.02rem; font-weight: 600; margin: 1.5em 0 .4em; color: var(--slate-text); }
.hfb-prose a { color: var(--forest); text-decoration: underline; text-underline-offset: 2px; }
.hfb-prose a:hover { color: var(--orange); }
.hfb-prose ul, .hfb-prose ol { margin: 0 0 1.3em; padding-left: 1.35em; }
.hfb-prose li { margin-bottom: .55em; }
.hfb-prose strong { font-weight: 600; }

/* Tables — green header, zebra rows, scrollable */
.hfb-prose table { width: 100%; border-collapse: collapse; font-family: var(--sans); font-size: 14.5px; margin: 1.8em 0; }
.hfb-prose .hfb-tablewrap { overflow-x: auto; margin: 1.8em 0; max-width: 100%; }
.hfb-prose .hfb-tablewrap table { margin: 0; }
.hfb-prose th { background: var(--forest); color: var(--paper); text-align: left; padding: 11px 13px; font-weight: 600; }
.hfb-prose td { padding: 10px 13px; border-bottom: 1px solid var(--hairline); vertical-align: top; }
.hfb-prose tbody tr:nth-child(even) { background: var(--panel-tan); }

/* Callouts — four variants per the spec */
.hfb-prose blockquote {
  margin: 1.8em 0; padding: 15px 20px; border-radius: var(--r-call);
  background: var(--panel-tan); border-left: 4px solid var(--gold);
  font-family: var(--sans); font-size: 15.5px; line-height: 1.6;
}
.hfb-prose blockquote p { margin: 0 0 .6em; }
.hfb-prose blockquote p:last-child { margin: 0; }
.hfb-prose blockquote.safety { background: #F9EBE1; border-left-color: var(--orange); }
.hfb-prose blockquote.legal  { background: #EAECEC; border-left-color: var(--slate); }
.hfb-prose blockquote.note   { background: #E9EDE9; border-left-color: var(--forest); }
.hfb-prose blockquote strong:first-child { font-family: var(--mono); font-size: .72rem; text-transform: uppercase; letter-spacing: .12em; display: block; margin-bottom: 6px; }
.hfb-prose blockquote.safety strong:first-child { color: var(--orange); }
.hfb-prose blockquote.legal  strong:first-child { color: var(--slate-text); }
.hfb-prose blockquote.note   strong:first-child { color: var(--forest); }

/* Figures */
.hfb-prose figure { margin: 2.2em 0; max-width: 100%; }
.hfb-prose figure img { width: 100%; border-radius: var(--r-call); background: var(--paper-card); }
.hfb-prose figcaption { font-family: var(--serif); font-style: italic; font-size: .95rem; line-height: 1.6; color: var(--slate-text); margin-top: 10px; }

/* ✓ / ✗ in comparison tables */
.hfb-prose td:has(> :only-child) { white-space: normal; }

/* Chapter foot */
.hfb-chapfoot { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 48px; max-width: var(--measure); }
@media (max-width: 620px) { .hfb-chapfoot { grid-template-columns: 1fr; } }
.hfb-chapfoot a { border: 1px solid var(--hairline); border-radius: var(--r-card); padding: 17px 19px; color: var(--ink); background: var(--paper-card); }
.hfb-chapfoot a:hover { border-color: var(--forest); }
.hfb-chapfoot span { display: block; font-family: var(--mono); font-size: .68rem; text-transform: uppercase; letter-spacing: .12em; color: var(--warm-gray); margin-bottom: 5px; }
.hfb-chapfoot strong { font-weight: 600; font-size: 15.5px; }
.hfb-chapfoot .hfb-next { text-align: right; }

/* ===========================================================================
   Gate / thanks
   ========================================================================= */
.hfb-gate { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(28px,5vw,60px); padding: clamp(36px,5vw,72px) 0; align-items: start; }
@media (max-width: 900px) { .hfb-gate { grid-template-columns: 1fr; } }
.hfb-gate h1 { font-size: clamp(1.9rem,4vw,2.7rem); font-weight: 800; letter-spacing: -.025em; margin: 14px 0 0; }
.hfb-gate__list { list-style: none; padding: 0; margin: 24px 0 0; font-size: 15.5px; color: var(--slate-text); }
.hfb-gate__list li { position: relative; padding-left: 26px; margin-bottom: 10px; }
.hfb-gate__list li::before { content: "✓"; position: absolute; left: 0; color: var(--forest); font-weight: 700; }

.hfb-form { background: var(--paper-card); border: 1px solid var(--hairline); border-radius: var(--r-card); padding: clamp(22px,3vw,32px); }
.hfb-form label { display: block; font-family: var(--mono); font-size: .7rem; text-transform: uppercase; letter-spacing: .12em; color: var(--slate-text); margin: 17px 0 6px; }
.hfb-form label:first-of-type { margin-top: 0; }
.hfb-form input[type=email], .hfb-form input[type=text], .hfb-form select {
  width: 100%; padding: 12px 14px; font-family: var(--sans); font-size: 15px;
  border: 1px solid var(--hairline); border-radius: var(--r-btn); background: #fff; color: var(--ink);
}
.hfb-form input:focus, .hfb-form select:focus { border-color: var(--forest); outline: none; }
.hfb-form__check { display: flex; gap: 10px; align-items: flex-start; margin: 20px 0 0; font-size: 14px; color: var(--slate-text); }
.hfb-form .hfb-btn { width: 100%; margin-top: 20px; }
.hfb-form__fine { font-family: var(--mono); font-size: .68rem; color: var(--warm-gray); margin: 12px 0 0; text-align: center; }
.hfb-form__error { background: #F9EBE1; border-left: 4px solid var(--orange); padding: 11px 14px; font-size: 14px; margin-bottom: 18px; border-radius: var(--r-call); }
.hfb-hp { position: absolute; left: -9999px; }

.hfb-thanks { text-align: center; max-width: 580px; margin: 0 auto; padding: clamp(44px,7vw,100px) 0; }
.hfb-thanks__mark { width: 56px; height: 56px; border-radius: 50%; background: rgba(51,70,58,.1); color: var(--forest); font-size: 26px; display: flex; align-items: center; justify-content: center; margin: 0 auto 22px; }
.hfb-thanks h1 { font-size: clamp(1.8rem,4vw,2.6rem); font-weight: 800; letter-spacing: -.02em; margin: 12px 0 0; }
.hfb-thanks p { color: var(--slate-text); }

@media (prefers-reduced-motion: no-preference) {
  .hfb-fade { animation: hfbFade .36s ease both; }
  @keyframes hfbFade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
}

@media print {
  .hfb-header, .hfb-footer, .hfb-toc, .hfb-chapfoot { display: none; }
  body { background: #fff; }
  .hfb-reader { grid-template-columns: 1fr; }
}
