/* ==========================================================================
   Nomad Budget Guide — design system
   Palette measured from nomad-logo.webp, contrast-verified for WCAG AA.
   ========================================================================== */

/* --- Tokens ------------------------------------------------------------- */
:root {
  /* Brand — measured from the logo */
  --brand-orange:      #E4631A; /* display type, accents, icons (3.23:1 — large only) */
  --brand-orange-ink:  #B14C0C; /* links + small text (5.04:1 on paper) */
  --brand-orange-btn:  #C25513; /* button fill, holds white text at 4.56:1 */
  --brand-brown:       #443837; /* body copy (10.55:1 on paper) */
  --brand-brown-deep:  #2E2523; /* footer */

  /* Surfaces */
  --paper:  #FBF7F2;
  --card:   #FFFFFF;
  --tint:   #FDF0E4;
  --line:   #E8DED4;
  --line-strong: #D9CBBE;

  /* Text */
  --ink:        var(--brand-brown);
  --ink-muted:  #6A5A54; /* 6.15:1 */
  --ink-on-dark: #FBF7F2;
  --ink-on-dark-muted: #C9B8AE;

  /* Type */
  --font-display: "Caveat Brush", "Segoe Script", "Bradley Hand", cursive;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;

  --step--1: clamp(0.83rem, 0.80rem + 0.15vw, 0.89rem);
  --step-0:  clamp(1.06rem, 1.00rem + 0.25vw, 1.19rem);
  --step-1:  clamp(1.25rem, 1.15rem + 0.45vw, 1.50rem);
  --step-2:  clamp(1.50rem, 1.30rem + 0.90vw, 2.00rem);
  --step-3:  clamp(1.85rem, 1.50rem + 1.60vw, 2.75rem);
  --step-4:  clamp(2.30rem, 1.60rem + 3.20vw, 4.00rem);

  /* Space */
  --space-2xs: 0.35rem;
  --space-xs:  0.6rem;
  --space-s:   1rem;
  --space-m:   1.5rem;
  --space-l:   2.5rem;
  --space-xl:  4rem;
  --space-2xl: 6rem;

  --container: 71.25rem; /* 1140px */
  --measure:   68ch;

  --radius: 0.5rem;
  --radius-lg: 0.75rem;
  --shadow-sm: 0 1px 2px rgba(68, 56, 55, 0.06),
               0 2px 8px rgba(68, 56, 55, 0.04);
  --shadow-md: 0 2px 4px rgba(68, 56, 55, 0.07),
               0 8px 24px rgba(68, 56, 55, 0.07);
}

/* --- Reset -------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 6rem;
}

body {
  margin: 0;
  background-color: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

img, svg, video { display: block; max-width: 100%; height: auto; }
img { background-color: var(--line); }

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--space-s);
  line-height: 1.15;
  color: var(--ink);
  font-weight: 700;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

p { margin: 0 0 var(--space-s); text-wrap: pretty; }
ul, ol { margin: 0 0 var(--space-s); padding-left: 1.4em; }
li { margin-bottom: 0.4em; }

a { color: var(--brand-orange-ink); text-underline-offset: 0.18em; }
a:hover { color: var(--brand-brown); }

:focus-visible {
  outline: 3px solid var(--brand-orange);
  outline-offset: 2px;
  border-radius: 2px;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: var(--space-l) 0;
}

/* --- Layout ------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: clamp(1.1rem, 4vw, 2.5rem);
}

.section { padding-block: var(--space-xl); }
.section--tight { padding-block: var(--space-l); }
.section--tint { background: var(--tint); }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--brand-brown);
  color: var(--paper);
  padding: 0.75rem 1.25rem;
  z-index: 999;
  border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; }

/* --- Header ------------------------------------------------------------- */
.site-header {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: saturate(140%) blur(6px);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-m);
  min-height: 4.5rem;
  padding-block: 0.5rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  flex-shrink: 0;
}
.brand__logo { width: 150px; height: auto; background: none; }

.site-nav ul {
  display: flex;
  align-items: center;
  gap: clamp(0.75rem, 2vw, 1.75rem);
  list-style: none;
  margin: 0;
  padding: 0;
}
.site-nav li { margin: 0; }
.site-nav a {
  color: var(--ink);
  text-decoration: none;
  font-size: var(--step--1);
  font-weight: 600;
  letter-spacing: 0.01em;
  padding-block: 0.35rem;
  border-bottom: 2px solid transparent;
}
.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--brand-orange-ink);
  border-bottom-color: var(--brand-orange);
}

/* --- Buttons ------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--brand-orange-btn);
  color: #fff;
  font-weight: 600;
  font-size: var(--step--1);
  text-decoration: none;
  padding: 0.75rem 1.35rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: background-color 0.15s ease, transform 0.15s ease;
}
.btn:hover { background: #A3460A; color: #fff; transform: translateY(-1px); }
.btn--ghost {
  background: transparent;
  color: var(--brand-brown);
  border-color: var(--line-strong);
}
.btn--ghost:hover { background: var(--tint); color: var(--brand-brown); }

/* --- Hero --------------------------------------------------------------- */
.hero { padding-block: clamp(2.5rem, 6vw, 5rem) var(--space-xl); }
.hero--compact { padding-block: clamp(1.75rem, 4vw, 3rem) var(--space-l); }

.hero__eyebrow {
  display: inline-block;
  font-size: var(--step--1);
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--brand-orange-ink);
  margin-bottom: var(--space-xs);
}

.hero h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--step-4);
  line-height: 0.98;
  letter-spacing: 0.005em;
  color: var(--brand-brown);
  margin-bottom: var(--space-m);
  max-width: 20ch;
}

.hero__lede {
  font-size: var(--step-1);
  line-height: 1.5;
  color: var(--ink-muted);
  max-width: 52ch;
  margin-bottom: var(--space-m);
}

.hero__actions { display: flex; flex-wrap: wrap; gap: var(--space-xs); }

/* --- Cards -------------------------------------------------------------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
  gap: var(--space-m);
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-m);
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.18s ease, transform 0.18s ease,
              border-color 0.18s ease;
  height: 100%;
}
.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--line-strong);
}
.card__kicker {
  font-size: var(--step--1);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand-orange-ink);
  margin-bottom: 0.4rem;
}
.card h3 {
  font-size: var(--step-1);
  margin-bottom: 0.5rem;
  letter-spacing: -0.01em;
}
.card p {
  font-size: var(--step--1);
  color: var(--ink-muted);
  margin-bottom: 0;
  flex-grow: 1;
}
.card__meta {
  margin-top: var(--space-s);
  font-size: var(--step--1);
  color: var(--ink-muted);
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* --- Section headings --------------------------------------------------- */
.section-head { margin-bottom: var(--space-m); max-width: 46ch; }
.section-head h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--step-3);
  color: var(--brand-brown);
  line-height: 1;
  margin-bottom: 0.5rem;
}
.section-head p { color: var(--ink-muted); margin: 0; }

/* --- Hand-drawn divider ------------------------------------------------- */
.squiggle {
  display: block;
  width: 120px;
  height: 12px;
  margin: var(--space-m) 0;
  color: var(--brand-orange);
}
.squiggle--center { margin-inline: auto; }

/* --- Breadcrumbs -------------------------------------------------------- */
.breadcrumbs {
  font-size: var(--step--1);
  color: var(--ink-muted);
  padding-top: var(--space-m);
}
.breadcrumbs ol {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0;
  padding: 0;
}
.breadcrumbs li { margin: 0; display: flex; gap: 0.45rem; }
.breadcrumbs li + li::before { content: "/"; color: var(--line-strong); }
.breadcrumbs a { color: var(--ink-muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--brand-orange-ink); text-decoration: underline; }

/* --- Article ------------------------------------------------------------ */
.article-header { padding-block: var(--space-m) var(--space-s); }
.article-header h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--step-3);
  line-height: 1.02;
  color: var(--brand-brown);
  margin-bottom: var(--space-xs);
  max-width: 24ch;
}
.article-header__standfirst {
  font-size: var(--step-1);
  line-height: 1.5;
  color: var(--ink-muted);
  max-width: 60ch;
  margin-bottom: var(--space-s);
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.1rem;
  font-size: var(--step--1);
  color: var(--ink-muted);
  padding-block: var(--space-xs);
  border-block: 1px solid var(--line);
  margin-bottom: var(--space-l);
}
.article-meta__item { display: inline-flex; align-items: center; gap: 0.35rem; }
.article-meta svg { width: 15px; height: 15px; color: var(--brand-orange); }

.prose { max-width: var(--measure); }
.prose > h2 {
  font-size: var(--step-2);
  margin-top: var(--space-l);
  margin-bottom: var(--space-s);
  padding-top: var(--space-s);
}
.prose > h3 {
  font-size: var(--step-1);
  margin-top: var(--space-m);
  margin-bottom: 0.6rem;
}
.prose > h2 + h3 { margin-top: 0; }
.prose p, .prose li { color: var(--ink); }
.prose strong { font-weight: 700; color: var(--brand-brown); }

.prose ul li::marker { color: var(--brand-orange); }
.prose ol li::marker { color: var(--brand-orange-ink); font-weight: 700; }

/* Quick answer / callout */
.answer {
  background: var(--tint);
  border-left: 4px solid var(--brand-orange);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: var(--space-m);
  margin-bottom: var(--space-m);
  max-width: var(--measure);
}
.answer__label {
  display: block;
  font-size: var(--step--1);
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--brand-orange-ink);
  margin-bottom: 0.4rem;
}
.answer p { margin-bottom: 0.6rem; }
.answer p:last-child { margin-bottom: 0; }

.note {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: var(--space-s) var(--space-m);
  background: var(--card);
  font-size: var(--step--1);
  color: var(--ink-muted);
  margin-block: var(--space-m);
  max-width: var(--measure);
}
.note strong { color: var(--brand-brown); }

/* Tables */
.table-wrap {
  overflow-x: auto;
  margin-block: var(--space-m);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  -webkit-overflow-scrolling: touch;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--step--1);
  min-width: 34rem;
}
caption {
  caption-side: top;
  text-align: left;
  padding: var(--space-s) var(--space-s) 0.25rem;
  font-weight: 700;
  color: var(--brand-brown);
}
th, td {
  padding: 0.7rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
thead th {
  background: var(--tint);
  font-weight: 700;
  color: var(--brand-brown);
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:nth-child(even) { background: #FDFBF8; }

/* TOC */
.toc {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-m);
  margin-bottom: var(--space-l);
  max-width: var(--measure);
}
.toc__title {
  font-size: var(--step--1);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 0.6rem;
}
.toc ol { margin: 0; padding-left: 1.2em; font-size: var(--step--1); }
.toc li { margin-bottom: 0.3rem; }
.toc a { color: var(--ink); text-decoration: none; }
.toc a:hover { color: var(--brand-orange-ink); text-decoration: underline; }

/* FAQ */
.faq { max-width: var(--measure); }
.faq details {
  border-bottom: 1px solid var(--line);
  padding-block: var(--space-s);
}
.faq details:first-of-type { border-top: 1px solid var(--line); }
.faq summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--brand-brown);
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-s);
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+";
  color: var(--brand-orange);
  font-size: 1.4em;
  line-height: 1;
  flex-shrink: 0;
}
.faq details[open] summary::after { content: "–"; }
.faq details p { margin-top: 0.7rem; margin-bottom: 0; color: var(--ink); }

/* Sources */
.sources {
  font-size: var(--step--1);
  color: var(--ink-muted);
  max-width: var(--measure);
  border-top: 1px solid var(--line);
  padding-top: var(--space-s);
  margin-top: var(--space-l);
}
.sources h2 {
  font-size: var(--step--1);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 0.5rem;
}
.sources ul { padding-left: 1.1em; }
.sources li { margin-bottom: 0.35rem; }
.sources a { word-break: break-word; }

/* Author box */
.author-box {
  display: flex;
  gap: var(--space-m);
  align-items: flex-start;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-m);
  margin-top: var(--space-xl);
  max-width: var(--measure);
}
.author-box__avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--tint);
}
.author-box__body p { font-size: var(--step--1); color: var(--ink-muted); }
.author-box__body p:last-child { margin-bottom: 0; }
.author-box__name {
  font-weight: 700;
  color: var(--brand-brown);
  font-size: var(--step-0);
}

/* --- Footer ------------------------------------------------------------- */
.site-footer {
  background: var(--brand-brown-deep);
  color: var(--ink-on-dark);
  padding-block: var(--space-xl) var(--space-l);
  margin-top: var(--space-2xl);
}
.site-footer a { color: var(--ink-on-dark); text-decoration: none; }
.site-footer a:hover { color: #fff; text-decoration: underline; }
.site-footer__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr));
  gap: var(--space-l);
  margin-bottom: var(--space-l);
}
.site-footer h2 {
  font-size: var(--step--1);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-on-dark-muted);
  margin-bottom: var(--space-s);
  font-weight: 700;
}
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin-bottom: 0.45rem; font-size: var(--step--1); }
.site-footer__brand img { width: 170px; height: auto; background: none; }
.site-footer__brand p {
  color: var(--ink-on-dark-muted);
  font-size: var(--step--1);
  margin-top: var(--space-s);
  max-width: 30ch;
}
.site-footer__legal {
  border-top: 1px solid rgba(251, 247, 242, 0.15);
  padding-top: var(--space-m);
  font-size: var(--step--1);
  color: var(--ink-on-dark-muted);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-s);
  justify-content: space-between;
}

/* --- Link list ---------------------------------------------------------- */
.link-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: var(--measure);
  border-top: 1px solid var(--line);
}
.link-list li {
  margin: 0;
  border-bottom: 1px solid var(--line);
}
.link-list a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-s);
  padding: 0.85rem 0;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
}
.link-list a::after {
  content: "→";
  color: var(--brand-orange);
  font-weight: 400;
  flex-shrink: 0;
  transition: transform 0.15s ease;
}
.link-list a:hover { color: var(--brand-orange-ink); }
.link-list a:hover::after { transform: translateX(3px); }
.link-list li.is-pending {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-s);
  padding: 0.85rem 0;
  color: var(--ink-muted);
  font-weight: 400;
}
.link-list li.is-pending span:last-child {
  font-size: var(--step--1);
  font-style: italic;
  flex-shrink: 0;
}

/* --- Evidence labels ---------------------------------------------------- */
.evidence {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.16rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
  vertical-align: 0.12em;
  border: 1px solid transparent;
}
.evidence--card {
  background: #E7F0E9;
  color: #2F5D3A;
  border-color: #C9DED0;
}
.evidence--logged {
  background: #FDF0E4;
  color: #8A3D08;
  border-color: #F0D5BB;
}
.evidence--range {
  background: #EEEAE6;
  color: #55463F;
  border-color: #DDD3CB;
}

/* --- Article status banner ---------------------------------------------- */
.status-banner {
  background: #FDF0E4;
  border: 1px solid #F0D5BB;
  border-left: 4px solid var(--brand-orange);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: var(--space-s) var(--space-m);
  margin-bottom: var(--space-m);
  font-size: var(--step--1);
  max-width: var(--measure);
}
.status-banner strong { color: var(--brand-brown); }

/* --- Latest guides list ------------------------------------------------ */
.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: var(--measure);
  border-top: 1px solid var(--line);
}
.post-list li { margin: 0; border-bottom: 1px solid var(--line); }
.post-list a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-s);
  padding: 0.8rem 0;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
}
.post-list a:hover { color: var(--brand-orange-ink); }
.post-list time {
  color: var(--ink-muted);
  font-weight: 400;
  font-size: var(--step--1);
  white-space: nowrap;
  flex-shrink: 0;
}

/* --- Utilities ---------------------------------------------------------- */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.text-muted { color: var(--ink-muted); }
.stack > * + * { margin-top: var(--space-s); }
.center { text-align: center; }
.mx-auto { margin-inline: auto; }

/* --- Responsive --------------------------------------------------------- */
@media (max-width: 46rem) {
  .site-header__inner { flex-wrap: wrap; gap: var(--space-xs); }
  .site-nav { width: 100%; order: 3; }
  .site-nav ul { overflow-x: auto; padding-bottom: 0.35rem; gap: 1.1rem; }
  .site-nav a { white-space: nowrap; }
  .hero h1 { font-size: clamp(2rem, 11vw, 3rem); }
  .author-box { flex-direction: column; }
  .article-meta { gap: 0.4rem 0.9rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  .site-header, .site-footer, .toc, .author-box { display: none; }
  body { background: #fff; }
  a { color: #000; }
}
