/* =========================================================================
   Starting a Business in Scotland — stylesheet
   Hanken Grotesk (headings/UI) + Lora (body). One light colour system,
   in Scottish saltire blue. Built for calm, comfortable reading.
   ========================================================================= */

/* --- Fonts (self-hosted, latin subset) --- */
@font-face { font-family: "Hanken Grotesk"; font-style: normal; font-weight: 500; font-display: swap; src: url("/assets/fonts/hankengrotesk-500.woff2") format("woff2"); }
@font-face { font-family: "Hanken Grotesk"; font-style: normal; font-weight: 600; font-display: swap; src: url("/assets/fonts/hankengrotesk-600.woff2") format("woff2"); }
@font-face { font-family: "Hanken Grotesk"; font-style: normal; font-weight: 700; font-display: swap; src: url("/assets/fonts/hankengrotesk-700.woff2") format("woff2"); }
@font-face { font-family: "Hanken Grotesk"; font-style: normal; font-weight: 800; font-display: swap; src: url("/assets/fonts/hankengrotesk-800.woff2") format("woff2"); }
@font-face { font-family: "Lora"; font-style: normal; font-weight: 400; font-display: swap; src: url("/assets/fonts/lora-400.woff2") format("woff2"); }
@font-face { font-family: "Lora"; font-style: normal; font-weight: 500; font-display: swap; src: url("/assets/fonts/lora-500.woff2") format("woff2"); }
@font-face { font-family: "Lora"; font-style: normal; font-weight: 600; font-display: swap; src: url("/assets/fonts/lora-600.woff2") format("woff2"); }
@font-face { font-family: "Lora"; font-style: italic; font-weight: 400; font-display: swap; src: url("/assets/fonts/lora-400italic.woff2") format("woff2"); }

:root {
  color-scheme: light;
  /* Brand palette (a Scottish saltire blue + deep navy) */
  --navy:      #002b49;
  --blue:      #0065bd;   /* Scottish Government saltire blue */
  --blue-dark: #004a8c;
  --teal:      #12707a;

  /* Light theme */
  --bg:         #f6f7f9;
  --surface:    #ffffff;
  --surface-2:  #eef1f5;
  --text:       #17222e;
  --text-soft:  #46586a;
  --border:     #d8dee6;
  --brand:      var(--blue);
  --brand-ink:  var(--navy);
  --link:       #0058a6;
  --link-hover: #003f77;
  --focus:      #b5651d;   /* warm high-contrast focus ring */

  /* Callout accents */
  --legal:     #7a3ea3;
  --legal-bg:  #f4ecfa;
  --watch:     #b23a1e;
  --watch-bg:  #fbeee9;
  --jargon:    #1d6fb8;
  --jargon-bg: #e9f2fb;
  --tip:       #1f7a45;
  --tip-bg:    #e8f5ec;
  --check:     #1f7a45;
  --check-bg:  #e8f5ec;
  --scot:      #0a4d8c;
  --scot-bg:   #e6eef7;
  --money:     #8a6d00;
  --money-bg:  #fbf4dd;
  --time:      #b23a1e;
  --time-bg:   #fbeee9;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16,32,48,.06), 0 4px 16px rgba(16,32,48,.05);
  --maxread: 44rem;

  --font-sans:  "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-serif: "Lora", Georgia, Cambria, "Times New Roman", serif;
  --font: var(--font-sans); /* legacy alias used by inline SVG diagrams */
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
}

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

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

body {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(1.05rem, 1.0rem + 0.32vw, 1.2rem);
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-underline-offset: 2px;
}

/* Headings and all interface chrome use the sans; long-form prose uses the serif. */
h1, h2, h3, h4,
.brand, .brand-title, .brand-tag, .nav-toggle,
.site-nav, .nav-heading, .nav-list, .eyebrow,
.callout-label, .btn, caption, thead th, tbody th,
.card h3, .pager, .timeline-badge, .timeline h3, .steps,
.gloss-term, .gloss-jump, .gloss-more, .footer-meta {
  font-family: var(--font-sans);
}

.wrap { width: 100%; max-width: 74rem; margin-inline: auto; padding-inline: 1.25rem; }

/* --- Links --- */
a { color: var(--link); text-decoration-thickness: 1px; }
a:hover { color: var(--link-hover); }
a:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 3px;
}
.gloss-link {
  text-decoration: underline dotted;
  text-decoration-color: color-mix(in srgb, var(--brand) 60%, transparent);
  color: inherit;
}
.gloss-link:hover { color: var(--link-hover); text-decoration-style: solid; }

/* --- Skip link --- */
.skip-link {
  position: absolute; left: 0.5rem; top: -3.5rem;
  background: var(--brand-ink); color: #fff; padding: .6rem 1rem;
  border-radius: var(--radius-sm); z-index: 50; transition: top .15s;
}
.skip-link:focus { top: 0.5rem; color: #fff; }

/* --- Header --- */
.site-header {
  background: var(--navy);
  color: #fff;
  border-bottom: 3px solid var(--blue);
  position: sticky; top: 0; z-index: 20;
}
.site-header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-block: .7rem; }
.brand { display: flex; align-items: center; gap: .7rem; color: #fff; text-decoration: none; }
.brand:hover { color: #fff; }
.brand-mark { display: inline-flex; line-height: 1; }

/* --- Saltire (Scottish flag) --- */
.saltire { display: inline-block; border-radius: 2px; vertical-align: -0.12em; }
.brand-flag { width: 32px; height: 19px; border-radius: 3px; box-shadow: 0 0 0 1px rgba(255,255,255,.3); }
.icon-flag { width: 1.35em; height: 0.81em; }
.callout-icon .icon-flag { width: 22px; height: 13px; vertical-align: middle; }
.card h3 .icon-flag { margin-right: .15rem; }
.brand-text { display: flex; flex-direction: column; }
.brand-title { font-weight: 700; font-size: 1.08rem; letter-spacing: .1px; }
.brand-tag { font-size: .82rem; color: #b9d4ee; }
.nav-toggle {
  display: none;
  font: inherit; font-weight: 600;
  color: #fff; background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.35); border-radius: var(--radius-sm);
  padding: .45rem .8rem; cursor: pointer;
}

/* --- Layout: sidebar + content --- */
.layout {
  display: grid;
  grid-template-columns: 17rem minmax(0, 1fr);
  gap: 2.5rem;
  align-items: start;
  padding-block: 2rem 1rem;
}
.site-nav {
  position: sticky; top: 4.6rem;
  align-self: start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  max-height: calc(100vh - 6rem);
  overflow: auto;
}
.nav-heading { margin: .1rem 0 .6rem; font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; color: var(--text-soft); }
.nav-list { list-style: none; margin: 0; padding: 0; counter-reset: none; }
.nav-list li { margin: 0; }
.nav-list a {
  display: flex; align-items: center; gap: .6rem;
  padding: .5rem .55rem; border-radius: var(--radius-sm);
  color: var(--text); text-decoration: none; font-size: .95rem; line-height: 1.3;
}
.nav-list a:hover { background: var(--surface-2); }
.nav-list a[aria-current="page"] { background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand-ink); font-weight: 600; }
.nav-num {
  flex: 0 0 auto; width: 1.55rem; height: 1.55rem;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--text-soft);
  border-radius: 50%; font-size: .8rem; font-weight: 700;
}
.nav-list a[aria-current="page"] .nav-num { background: var(--brand); color: #fff; }

/* --- Content --- */
.content { min-width: 0; }
.content > * { max-width: var(--maxread); }
.content > .full, .content .diagram, .content > .cards, .content > .pager, .content > .table-scroll { max-width: none; }

.page-head { margin-bottom: 1.6rem; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .78rem; font-weight: 700; color: var(--brand); margin: 0 0 .4rem; }
h1 { font-size: clamp(1.9rem, 1.4rem + 1.9vw, 2.75rem); font-weight: 800; line-height: 1.12; letter-spacing: -.02em; color: var(--brand-ink); margin: 0 0 .3rem; }
.standfirst { font-size: 1.2rem; line-height: 1.55; color: var(--text-soft); margin: .5rem 0 0; }

h2 { font-size: clamp(1.4rem, 1.15rem + .8vw, 1.8rem); font-weight: 700; line-height: 1.2; color: var(--brand-ink); margin: 2.5rem 0 .6rem; padding-top: .4rem; letter-spacing: -.015em; }
h3 { font-size: 1.22rem; font-weight: 700; color: var(--brand-ink); margin: 1.8rem 0 .4rem; letter-spacing: -.01em; }
h2 + h3 { margin-top: 1rem; }
p, ul, ol { margin: 0 0 1rem; }
li { margin: .3rem 0; }
li > ul, li > ol { margin-top: .3rem; margin-bottom: .3rem; }
strong { color: var(--brand-ink); }
small { color: var(--text-soft); }
hr { border: none; border-top: 1px solid var(--border); margin: 2.2rem 0; }

/* Heading anchor links from markdown-it-anchor */
h2 a.header-anchor, h3 a.header-anchor { color: inherit; text-decoration: none; }
h2 a.header-anchor:hover, h3 a.header-anchor:hover { text-decoration: underline; }

/* Lead paragraph */
.lead { font-size: 1.12rem; color: var(--text); }

/* --- Callouts --- */
.callout {
  --c: var(--jargon); --cbg: var(--jargon-bg);
  margin: 1.5rem 0; padding: 1rem 1.15rem;
  background: var(--cbg);
  border: 1px solid color-mix(in srgb, var(--c) 35%, var(--border));
  border-left: 5px solid var(--c);
  border-radius: var(--radius-sm);
}
.callout > :last-child { margin-bottom: 0; }
.callout-body > :last-child { margin-bottom: 0; }
.callout-label {
  display: flex; align-items: center; gap: .5rem;
  margin: 0 0 .5rem; font-weight: 700; color: var(--c);
  font-size: .92rem; letter-spacing: .01em;
}
.callout-icon { font-size: 1.1rem; }
.callout-legal     { --c: var(--legal);  --cbg: var(--legal-bg); }
.callout-watch     { --c: var(--watch);  --cbg: var(--watch-bg); }
.callout-jargon    { --c: var(--jargon); --cbg: var(--jargon-bg); }
.callout-tip       { --c: var(--tip);    --cbg: var(--tip-bg); }
.callout-checklist { --c: var(--check);  --cbg: var(--check-bg); }
.callout-scotland  { --c: var(--scot);   --cbg: var(--scot-bg); }
.callout-money     { --c: var(--money);  --cbg: var(--money-bg); }
.callout-time      { --c: var(--time);   --cbg: var(--time-bg); }

/* Checklist ticks */
.callout-checklist ul { list-style: none; padding-left: 0; }
.callout-checklist li { padding-left: 1.9rem; position: relative; }
.callout-checklist li::before {
  content: "☐"; position: absolute; left: 0; top: -.05rem;
  color: var(--check); font-size: 1.2rem; line-height: 1.4;
}

/* --- Tables --- */
.table-scroll {
  overflow-x: auto; margin: 1.7rem 0;
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); background: var(--surface);
}
table { border-collapse: collapse; width: 100%; font-size: .98rem; line-height: 1.5; }
caption {
  caption-side: top; text-align: left;
  font-weight: 700; font-size: 1.02rem; letter-spacing: .01em;
  color: #fff; background: var(--navy);
  padding: .75rem 1rem;
}
th, td { text-align: left; padding: .7rem 1rem; border-bottom: 1px solid var(--border); vertical-align: top; }
thead th {
  background: var(--surface-2); color: var(--brand-ink); font-weight: 700;
  font-size: .95rem; border-bottom: 2px solid var(--blue);
}
tbody th {
  background: color-mix(in srgb, var(--surface-2) 55%, var(--surface));
  color: var(--brand-ink); font-weight: 600;
}
tbody tr:last-child td, tbody tr:last-child th { border-bottom: none; }
tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 32%, transparent); }

/* --- Cards --- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1rem; margin: 1.5rem 0; padding: 0; list-style: none; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow);
}
.card h3 { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.card-cta { display: inline-block; margin-top: .3rem; font-weight: 600; }

/* Home hero */
.hero {
  background: linear-gradient(135deg, var(--navy), var(--blue-dark));
  color: #fff; border-radius: var(--radius); padding: 2rem 1.8rem;
  margin-bottom: 1.8rem; max-width: none;
}
.hero h1 { color: #fff; }
.hero p { color: #dbe9f6; font-size: 1.15rem; max-width: 40rem; }
.hero strong { color: #fff; }
.hero .btn { margin-top: .6rem; }

.btn {
  display: inline-block; background: var(--blue); color: #fff;
  padding: .7rem 1.2rem; border-radius: var(--radius-sm);
  font-weight: 600; text-decoration: none; border: 1px solid transparent;
}
.btn:hover { background: var(--blue-dark); color: #fff; }
.btn-ghost { background: transparent; border-color: rgba(255,255,255,.5); color: #fff; }
.btn-ghost:hover { background: rgba(255,255,255,.12); color: #fff; }

/* --- Diagrams --- */
.diagram { margin: 1.8rem 0; }
.diagram figure { margin: 0; }
.diagram svg { width: 100%; height: auto; display: block; }
.diagram figcaption { color: var(--text-soft); font-size: .9rem; margin-top: .5rem; }

/* --- Definition list / glossary --- */
.gloss-controls { margin: 1rem 0 1.5rem; }
.gloss-jump { display: flex; flex-wrap: wrap; gap: .3rem; list-style: none; padding: 0; margin: 0; }
.gloss-jump a { display: inline-grid; place-items: center; min-width: 2rem; padding: .3rem .5rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); text-decoration: none; font-weight: 700; }
.gloss-jump a:hover { background: var(--surface-2); }
.gloss-group { margin: 2rem 0; }
.gloss-group h2 { margin-top: 1rem; }
.gloss-entry {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--brand);
  border-radius: var(--radius-sm); padding: .9rem 1.1rem; margin: .7rem 0; scroll-margin-top: 5rem;
}
.gloss-entry:target { border-left-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 30%, transparent); }
.gloss-term { font-weight: 700; color: var(--brand-ink); font-size: 1.05rem; margin: 0 0 .25rem; }
.gloss-def { margin: 0; }
.gloss-more { display: inline-block; margin-top: .4rem; font-size: .92rem; font-weight: 600; }

/* --- Pager --- */
.pager { display: flex; justify-content: space-between; gap: 1rem; margin: 2.5rem 0 1rem; max-width: none; }
.pager a {
  display: flex; flex-direction: column; gap: .15rem; flex: 1 1 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .8rem 1rem; text-decoration: none; box-shadow: var(--shadow);
}
.pager a:hover { border-color: var(--brand); }
.pager-next { text-align: right; align-items: flex-end; }
.pager-dir { font-size: .82rem; color: var(--text-soft); }
.pager-title { font-weight: 600; color: var(--brand-ink); }

/* --- Timeline --- */
.timeline { list-style: none; margin: 1.5rem 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 1.15rem; top: .5rem; bottom: .5rem; width: 3px; background: var(--border); }
.timeline > li { position: relative; padding: 0 0 1.4rem 3.2rem; }
.timeline-badge {
  position: absolute; left: 0; top: 0; width: 2.35rem; height: 2.35rem;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--brand); color: #fff; font-weight: 700; font-size: .82rem;
  border: 3px solid var(--bg); box-shadow: 0 0 0 1px var(--border);
}
.timeline h3 { margin: .15rem 0 .4rem; }
.timeline .tl-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1.1rem; box-shadow: var(--shadow); }
.timeline .tl-card > :last-child { margin-bottom: 0; }

/* Steps (numbered flow) */
.steps { counter-reset: step; list-style: none; padding: 0; margin: 1.4rem 0; }
.steps > li { position: relative; padding-left: 3rem; margin: 0 0 1rem; }
.steps > li::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: 0; width: 2.1rem; height: 2.1rem;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--brand-ink); color: #fff; font-weight: 700;
}

/* Reassurance / callbox on home */
.note-soft { background: var(--surface-2); border-radius: var(--radius); padding: 1.1rem 1.3rem; }

/* --- Footer --- */
.site-footer { margin-top: 3rem; background: var(--navy); color: #cddff0; padding: 2rem 0; }
.site-footer a { color: #9fd0f5; }
.footer-disclaimer { max-width: 60rem; }
.footer-disclaimer strong { color: #fff; }
.footer-meta { font-size: .86rem; color: #8fb4d6; margin-bottom: 0; }

/* --- Mobile --- */
@media (max-width: 52rem) {
  .layout { grid-template-columns: 1fr; gap: 1.2rem; padding-top: 1rem; }
  .nav-toggle { display: inline-block; }
  .site-nav {
    position: static; max-height: none; display: none;
  }
  .site-nav.is-open { display: block; }
  .content > * { max-width: none; }
  .brand-tag { display: none; }
  .pager { flex-direction: column; }
  .pager-next { text-align: left; align-items: flex-start; }
}

/* --- Motion --- */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
html { scroll-behavior: smooth; }

/* --- Print --- */
@media print {
  .site-header, .site-nav, .nav-toggle, .pager, .skip-link { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .layout { display: block; padding: 0; }
  .content > * { max-width: none; }
  .callout, .card, .gloss-entry, .tl-card { break-inside: avoid; border: 1px solid #999; box-shadow: none; }
  a { color: #000; text-decoration: underline; }
  .site-footer { background: #fff; color: #000; border-top: 1px solid #999; }
}
