/*
Theme Name: LR MAD
Theme URI: https://www.lr-mad.co.uk/
Author: LR MAD editorial team
Description: Field-manual styled reference theme for a magazine on military, special and rare Land Rovers.
Version: 1.0.0
Requires at least: 6.5
Requires PHP: 8.1
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: lrmad
*/

/* ==========================================================================
   Fonts (self-hosted)
   ========================================================================== */
@font-face {
  font-family: 'Stardos Stencil';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('assets/fonts/stardos-stencil-v15-latin-regular.woff2') format('woff2');
}
@font-face {
  font-family: 'Stardos Stencil';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('assets/fonts/stardos-stencil-v15-latin-700.woff2') format('woff2');
}
@font-face {
  font-family: 'Barlow';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('assets/fonts/barlow-v13-latin-regular.woff2') format('woff2');
}
@font-face {
  font-family: 'Barlow';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('assets/fonts/barlow-v13-latin-italic.woff2') format('woff2');
}
@font-face {
  font-family: 'Barlow';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('assets/fonts/barlow-v13-latin-700.woff2') format('woff2');
}
@font-face {
  font-family: 'Cousine';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('assets/fonts/cousine-v31-latin-regular.woff2') format('woff2');
}
@font-face {
  font-family: 'Cousine';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('assets/fonts/cousine-v31-latin-700.woff2') format('woff2');
}

/* ==========================================================================
   Tokens
   ========================================================================== */
:root {
  --olive: #3c432d;
  --olive-deep: #2a2f1f;
  --khaki: #c1b59a;
  --khaki-dim: #b0a48a;
  --ink: #1a1a1a;
  --steel: #52525b;
  --paper: #ffffff;
  /* haulage: the motion personality — heavy start, slight settle */
  --haul: cubic-bezier(0.68, 0, 0.22, 1.35);
  --gear-1: 190ms;
  --gear-2: 400ms;
  --gear-3: 620ms;
  --stamp-face: 'Stardos Stencil', 'Arial Black', sans-serif;
  --body-face: 'Barlow', 'Helvetica Neue', sans-serif;
  --telex-face: 'Cousine', 'Courier New', monospace;
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--body-face);
  font-size: 1.075rem;
  line-height: 1.6;
  background-color: var(--olive);
  color: var(--ink);
  accent-color: var(--olive-deep);
  scrollbar-color: var(--khaki) var(--olive-deep);
}

::selection { background: var(--khaki); color: var(--ink); }

:focus-visible { outline: 3px solid var(--khaki); outline-offset: 2px; }

img { max-width: 100%; height: auto; display: block; }

.sheet-width { width: 100%; max-width: 1200px; margin-inline: auto; padding-inline: 1.5rem; }

.screen-reader-only {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ==========================================================================
   Type
   ========================================================================== */
.stamp {
  font-family: var(--stamp-face);
  text-transform: uppercase;
  line-height: 0.95;
  letter-spacing: -0.01em;
}

.telex {
  font-family: var(--telex-face);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

h1, h2, h3, h4, h5, h6 { margin: 0 0 0.6em; }

/* ==========================================================================
   Field-manual furniture
   ========================================================================== */
.plate {
  background-color: var(--khaki);
  border: 2px solid var(--ink);
  position: relative;
}

.bolt {
  position: absolute; width: 8px; height: 8px;
  background: #71717a; border-radius: 50%;
  box-shadow: inset -1px -1px 2px rgba(0, 0, 0, 0.4), 1px 1px 1px rgba(255, 255, 255, 0.1);
}
.bolt-tl { top: 10px; left: 10px; } .bolt-tr { top: 10px; right: 10px; }
.bolt-bl { bottom: 10px; left: 10px; } .bolt-br { bottom: 10px; right: 10px; }

.cutline { outline: 1px dashed var(--steel); outline-offset: -7px; }

.para-rule { border-left: 2px solid var(--steel); padding-left: 1.5rem; }

.form-tag {
  display: inline-block; background: var(--ink); color: var(--paper);
  font-family: var(--telex-face); font-size: 0.7rem; letter-spacing: 0.08em;
  padding: 0.25em 0.8em; text-transform: uppercase;
}

/* Section rule that draws itself in (reveal family: furniture, not content) */
.ruled-heading { display: flex; align-items: center; gap: 1rem; margin: 0 0 2rem; }
.ruled-heading .rule { height: 2px; flex-grow: 1; background: var(--ink); transform-origin: center; }
.ruled-heading h2, .ruled-heading h3 { margin: 0; color: var(--paper); }
@media (prefers-reduced-motion: no-preference) {
  .rule[data-draw] { transform: scaleX(0); }
  .rule.drawn { transform: scaleX(1); transition: transform var(--gear-3) var(--haul); }
}

/* Divider: tyre-tread strip */
hr, .copy hr {
  border: 0; height: 10px; margin: 3rem 0;
  background-image: repeating-linear-gradient(-45deg, var(--steel) 0 6px, transparent 6px 14px),
                    repeating-linear-gradient(45deg, var(--steel) 0 6px, transparent 6px 14px);
  background-size: 28px 5px;
  background-position: left top, left bottom;
  background-repeat: repeat-x;
  opacity: 0.55;
}

/* ==========================================================================
   Header
   ========================================================================== */
.masthead {
  background: var(--olive-deep); color: var(--paper);
  border-bottom: 4px solid var(--ink); padding: 1.5rem 0;
}
.masthead-flex { display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 1.5rem; }
.unit-badge { display: flex; align-items: center; gap: 1.5rem; text-decoration: none; color: inherit; }
.unit-badge svg { width: 80px; height: 80px; flex-shrink: 0; }
.unit-name { font-size: clamp(2.6rem, 6vw, 3.2rem); letter-spacing: -0.02em; margin: 0; color: var(--paper); }
.unit-motto {
  display: block; font-family: var(--telex-face); font-size: 0.7rem;
  text-transform: uppercase; letter-spacing: 0.3em; margin-top: 0.3rem; color: var(--khaki);
}

.duty-nav { display: flex; flex-wrap: wrap; gap: 0.5rem 2rem; margin: 0; padding: 0; list-style: none; counter-reset: duty; }
.duty-nav a {
  font-family: var(--telex-face); text-transform: uppercase; font-size: 0.85rem; font-weight: 700;
  color: var(--paper); text-decoration: none; padding: 0.25em 0.5em;
  transition: background var(--gear-1) var(--haul), color var(--gear-1) var(--haul);
}
.duty-nav li { counter-increment: duty; }
.duty-nav li::marker { content: none; }
.duty-nav a::before { content: counter(duty, decimal-leading-zero) '. '; color: var(--khaki); }
.duty-nav a:hover, .duty-nav a:focus-visible { background: var(--paper); color: var(--ink); }
.duty-nav a:hover::before, .duty-nav a:focus-visible::before { color: var(--ink); }

/* ==========================================================================
   Links — field-marker sweep (highlighter grows behind the text)
   ========================================================================== */
.copy a {
  color: var(--ink); text-decoration: none; font-weight: 700;
  background: linear-gradient(rgba(60, 67, 45, 0.35), rgba(60, 67, 45, 0.35)) no-repeat left 92% / 100% 0.18em;
  transition: background-size var(--gear-1) var(--haul), color var(--gear-1) var(--haul);
}
.copy a:hover, .copy a:focus-visible { background-size: 100% 95%; color: var(--paper); }

/* ==========================================================================
   Buttons — frame draws itself around the control
   ========================================================================== */
.control {
  display: inline-block; position: relative;
  font-family: var(--stamp-face); text-transform: uppercase; font-size: 1.3rem; line-height: 1;
  background: var(--ink); color: var(--paper);
  padding: 0.8em 1.6em; border: 0; cursor: pointer; text-decoration: none;
  transition: background var(--gear-1) var(--haul), transform var(--gear-1) var(--haul);
}
.control::after {
  content: ''; position: absolute; inset: -6px;
  border: 2px solid var(--ink); clip-path: inset(0 100% 0 0);
  transition: clip-path var(--gear-2) var(--haul);
}
.control:hover, .control:focus-visible { background: var(--olive); }
.control:hover::after, .control:focus-visible::after { clip-path: inset(0); }
.control:active { transform: translateY(2px); }

.control-light { background: var(--khaki); color: var(--ink); }
.control-light::after { border-color: var(--khaki); }

/* ==========================================================================
   Hero plate
   ========================================================================== */
.lead-plate { padding: 3rem 2rem; margin-top: 3rem; box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.6); }
.lead-grid { display: grid; grid-template-columns: 1fr; gap: 3rem; align-items: center; }
.lead-title { font-size: clamp(2.6rem, 8vw, 4.6rem); }
.lead-figure { border: 4px solid var(--ink); padding: 0.5rem; background: rgba(255, 255, 255, 0.5); position: relative; }
.lead-figure img { filter: grayscale(100%) contrast(125%); mix-blend-mode: multiply; width: 100%; }
.fig-caption {
  position: absolute; bottom: 1rem; left: 1rem;
  background: var(--ink); color: var(--paper);
  font-family: var(--telex-face); font-size: 0.62rem; padding: 0.3em 0.7em; text-transform: uppercase;
}

/* ==========================================================================
   Report cards (In depth)
   ========================================================================== */
.report-row { display: grid; grid-template-columns: 1fr; gap: 0; border: 2px solid var(--ink); }
.report {
  background: var(--khaki); padding: 1.5rem; display: block; text-decoration: none; color: var(--ink);
  border-bottom: 2px solid var(--ink);
  transition: background var(--gear-1) var(--haul);
}
.report:last-child { border-bottom: 0; }
.report:hover, .report:focus-visible { background: var(--khaki-dim); }
.report-ref { font-family: var(--telex-face); font-size: 0.62rem; text-transform: uppercase; margin-bottom: 1rem; }
.report-title { font-size: 1.5rem; margin-bottom: 1rem; }
.report-summary { font-size: 0.92rem; line-height: 1.55; margin-bottom: 1.4rem; }
.report-link { font-family: var(--telex-face); font-size: 0.72rem; font-weight: 700; text-decoration: underline; text-transform: uppercase; }

/* ==========================================================================
   Registry data cards
   ========================================================================== */
.registry-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.dossier {
  background: var(--khaki); border: 2px solid var(--ink); padding: 1rem 1.2rem;
  display: flex; flex-direction: column; text-decoration: none; color: var(--ink);
  transition: transform var(--gear-1) var(--haul);
}
.dossier:hover, .dossier:focus-visible { transform: translateY(-3px); }
.dossier-head {
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--ink); padding-bottom: 0.5rem; margin-bottom: 1rem;
}
.dossier-index { font-family: var(--telex-face); font-size: 0.62rem; font-weight: 700; text-transform: uppercase; }
.dossier-role { background: var(--ink); color: var(--paper); font-family: var(--telex-face); font-size: 0.58rem; padding: 0.15em 0.5em; text-transform: uppercase; }
.dossier-name { font-size: 1.3rem; margin: 0; }
.dossier table { margin-top: 1rem; width: 100%; border-collapse: collapse; font-family: var(--telex-face); font-size: 0.68rem; text-transform: uppercase; }
.dossier td { padding: 0.35em 0; border-bottom: 1px solid rgba(26, 26, 26, 0.2); }
.dossier td:last-child { text-align: right; }
.dossier-cta {
  margin-top: 1.2rem; font-size: 0.62rem; font-weight: 700; text-transform: uppercase;
  border: 1px solid var(--ink); padding: 0.6em; text-align: center; font-family: var(--telex-face);
  transition: background var(--gear-1) var(--haul), color var(--gear-1) var(--haul);
}
.dossier:hover .dossier-cta { background: var(--ink); color: var(--paper); }

/* ==========================================================================
   Article / copy
   ========================================================================== */
.doc-header { background: var(--olive-deep); color: var(--paper); padding: 3.5rem 0 2.5rem; border-bottom: 4px solid var(--ink); }
.doc-title { font-size: clamp(2.4rem, 7vw, 4.2rem); color: var(--paper); }
.doc-meta { font-family: var(--telex-face); font-size: 0.72rem; text-transform: uppercase; color: var(--khaki); }
.doc-meta a { color: inherit; }

.doc-body { background: var(--khaki); padding: 3rem 0 4rem; }
.copy { max-width: 44rem; margin-inline: auto; }
.copy > * + * { margin-top: 1.2em; }
.copy h2 { font-family: var(--stamp-face); text-transform: uppercase; font-size: 2rem; line-height: 1; margin-top: 2em; }
.copy h3 { font-family: var(--stamp-face); text-transform: uppercase; font-size: 1.5rem; line-height: 1; margin-top: 1.6em; }
.copy img { border: 3px solid var(--ink); }
.copy figure { margin: 2rem 0; }
.copy figcaption { font-family: var(--telex-face); font-size: 0.68rem; text-transform: uppercase; color: var(--steel); margin-top: 0.6rem; }
.copy ul, .copy ol { padding-left: 1.4em; }
.copy li::marker { color: var(--olive); font-weight: 700; }

.copy table { width: 100%; border-collapse: collapse; font-size: 0.95rem; background: var(--paper); border: 2px solid var(--ink); }
.copy th {
  font-family: var(--telex-face); text-transform: uppercase; font-size: 0.7rem;
  background: var(--ink); color: var(--paper); text-align: left; padding: 0.6em 0.8em;
}
.copy td { padding: 0.55em 0.8em; border-bottom: 1px solid rgba(26, 26, 26, 0.15); }
.table-scroll { overflow-x: auto; }

/* Blockquote: requisition slip pinned to the sheet */
.copy blockquote {
  position: relative; margin: 2.5rem 0; padding: 1.5rem 2rem;
  background: var(--paper); border: 1px solid var(--steel);
  font-style: italic;
}
.copy blockquote::before {
  content: ''; position: absolute; top: -7px; left: 50%; width: 14px; height: 14px;
  background: radial-gradient(circle at 35% 35%, #d4d4d8, #52525b 70%);
  border-radius: 50%; transform: translateX(-50%);
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.35);
}

/* FAQ — stencil chevron latch */
.query { border: 2px solid rgba(26, 26, 26, 0.45); margin-top: 1rem; background: var(--khaki); color: var(--ink); }
.query summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: 0.8em;
  font-weight: 700; font-size: 1.05rem; padding: 1rem 1.2rem;
}
.query summary::-webkit-details-marker { display: none; }
.query summary h3 { font-family: inherit; font-size: inherit; line-height: inherit; margin: 0; text-transform: none; letter-spacing: normal; }
.query summary::before {
  content: ''; flex-shrink: 0; width: 0.9em; height: 0.9em;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M2 6 L10 13 L18 6' fill='none' stroke='%233c432d' stroke-width='4' stroke-linecap='square'/%3E%3C/svg%3E") no-repeat center / contain;
  transition: transform var(--gear-2) var(--haul);
}
.query[open] summary::before { transform: rotate(-180deg); }
.query[open] summary { background: var(--khaki-dim); }
.query-body { padding: 0 1.2rem 1.2rem; }

/* Embed snippets (infographic attribution) — scroll inside the column, never overflow it */
pre {
  overflow-x: auto;
  max-width: 100%;
  background: var(--olive-deep);
  color: var(--khaki);
  border: 2px solid rgba(26, 26, 26, 0.45);
  padding: 1rem 1.2rem;
  font-size: 0.85rem;
  line-height: 1.5;
}

/* ==========================================================================
   Odometer reading-progress (articles; CSS scroll-driven)
   ========================================================================== */
.odometer {
  position: fixed; top: 0; left: 0; right: 0; height: 7px;
  pointer-events: none; z-index: 95; display: none;
  background: repeating-linear-gradient(90deg, var(--olive-deep) 0 34px, var(--khaki) 34px 36px);
}
.odometer-needle {
  height: 100%;
  background: repeating-linear-gradient(90deg, var(--khaki) 0 10px, var(--olive) 10px 12px);
  transform-origin: left center; transform: scaleX(0);
}
@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: scroll()) {
    .odometer { display: block; }
    .odometer-needle { animation: clock-up linear both; animation-timeline: scroll(root); }
  }
}
@keyframes clock-up { to { transform: scaleX(1); } }

/* ==========================================================================
   Archives / listings
   ========================================================================== */
.file-list { display: grid; grid-template-columns: 1fr; gap: 1.5rem; padding: 2.5rem 0 3.5rem; }
.pager { display: flex; gap: 0.6rem; justify-content: center; padding: 1.5rem 0 3.5rem; font-family: var(--telex-face); text-transform: uppercase; }
.pager .page-numbers { color: var(--paper); text-decoration: none; border: 2px solid rgba(255, 255, 255, 0.3); padding: 0.35em 0.75em; }
.pager .page-numbers.current, .pager .page-numbers:hover { background: var(--khaki); color: var(--ink); border-color: var(--khaki); }

/* Spec sheet (vehicle single) */
.spec-sheet {
  font-family: var(--telex-face); text-transform: uppercase; font-size: 0.8rem;
  background: var(--paper); border: 2px solid var(--ink); padding: 1.4rem; margin: 2rem 0;
  display: grid; grid-template-columns: 1fr; gap: 0.6rem; position: relative;
}
.spec-sheet dt { color: var(--olive); font-weight: 700; }
.spec-sheet dd { margin: 0 0 0.5rem; }

/* ==========================================================================
   Footer
   ========================================================================== */
.basefoot { background: var(--ink); color: var(--khaki); padding: 3.5rem 0 2rem; }
.basefoot-grid { display: grid; grid-template-columns: 1fr; gap: 2.5rem; border-bottom: 1px solid rgba(193, 181, 154, 0.2); padding-bottom: 2.5rem; margin-bottom: 2rem; }
.basefoot-brand { font-family: var(--stamp-face); text-transform: uppercase; font-size: 1.9rem; color: var(--paper); margin: 0 0 1rem; }
.basefoot-blurb { font-family: var(--telex-face); font-size: 0.72rem; text-transform: uppercase; line-height: 1.7; max-width: 24rem; }
.basefoot-title { font-family: var(--telex-face); font-size: 0.72rem; font-weight: 700; text-transform: uppercase; color: var(--paper); margin: 0 0 1.2rem; }
.basefoot ul { list-style: none; margin: 0; padding: 0; font-family: var(--telex-face); font-size: 0.7rem; text-transform: uppercase; }
.basefoot li + li { margin-top: 0.6rem; }
.basefoot a { color: var(--khaki); text-decoration: none; }
.basefoot a:hover, .basefoot a:focus-visible { text-decoration: underline; }
.basefoot a.control { color: var(--ink); }
.basefoot a.control:hover, .basefoot a.control:focus-visible { text-decoration: none; }
.basefoot-legal {
  display: flex; flex-direction: column; gap: 0.4rem; justify-content: space-between;
  font-family: var(--telex-face); font-size: 0.6rem; text-transform: uppercase; opacity: 0.6;
}

/* ==========================================================================
   404 — missing file
   ========================================================================== */
.missing-file { text-align: center; padding: 6rem 1rem; color: var(--paper); }
.missing-file .stamp { font-size: clamp(4rem, 16vw, 10rem); color: var(--khaki); }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (min-width: 768px) {
  .masthead-flex { flex-direction: row; align-items: center; }
  .report-row { grid-template-columns: repeat(3, 1fr); }
  .report { border-bottom: 0; border-right: 2px solid var(--ink); }
  .report:last-child { border-right: 0; }
  .registry-grid { grid-template-columns: repeat(2, 1fr); }
  .lead-grid { grid-template-columns: 1fr 1fr; }
  .basefoot-grid { grid-template-columns: 2fr 1fr 1fr; }
  .basefoot-legal { flex-direction: row; }
  .spec-sheet { grid-template-columns: max-content 1fr; }
  .spec-sheet dd { margin: 0; }
}
@media (min-width: 1024px) {
  .registry-grid { grid-template-columns: repeat(3, 1fr); }
}
