/* =========================================================================
   The Enterprise EPIC: companion site
   Design tokens and components taken from the book's locked design system
   (Design/Book_Design_System.md v1). Two contexts, exactly as in print:
   plates are parchment with ink and gold; text is near-black on white.
   ========================================================================= */

/* --- fonts ---------------------------------------------------------------- */
/* The book's typefaces (SIL Open Font Licence), served from this site so no
   visitor data goes to a font service. Each has a local fallback tuned to the
   same width and height, so text barely moves when the real font arrives. */

@font-face { font-family: "EB Garamond"; font-style: normal; font-weight: 400 500; font-display: swap; src: url("fonts/eb-garamond-400-500.woff2") format("woff2"); }
@font-face { font-family: "EB Garamond"; font-style: italic; font-weight: 400; font-display: swap; src: url("fonts/eb-garamond-400-italic.woff2") format("woff2"); }
@font-face { font-family: "Cormorant Garamond"; font-style: normal; font-weight: 600 700; font-display: swap; src: url("fonts/cormorant-garamond-600-700.woff2") format("woff2"); }
@font-face { font-family: "Alegreya Sans"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/alegreya-sans-500.woff2") format("woff2"); }
@font-face { font-family: "Alegreya Sans"; font-style: normal; font-weight: 700; font-display: swap; src: url("fonts/alegreya-sans-700.woff2") format("woff2"); }

@font-face { font-family: "EB Garamond Fallback"; src: local("Georgia"); size-adjust: 86.1%; ascent-override: 116.9%; descent-override: 34.6%; line-gap-override: 0%; }
@font-face { font-family: "Cormorant Garamond Fallback"; src: local("Georgia"); size-adjust: 88.1%; ascent-override: 104.9%; descent-override: 32.6%; line-gap-override: 0%; }
@font-face { font-family: "Alegreya Sans Fallback"; src: local("Arial"); size-adjust: 87.1%; ascent-override: 103.3%; descent-override: 34.4%; line-gap-override: 0%; }

:root {
  --ink: #20374F;
  --gold: #9C7D33;          /* rules, borders and large display type */
  --gold-text: #7D6429;     /* small gold text and gold buttons: meets WCAG AA on white and parchment */
  --gold-hi: #BD9C45;       /* on ink grounds only */
  --oxblood: #8E2F2A;       /* Vidura's Challenge only */
  --parchment: #EFE6CF;
  --parchment-deep: #E0D0AC;
  --parchment-pale: #FAF6EA;
  --sepia: #5C4A2E;
  --nb: #1A1A1A;
  --paper: #ffffff;
  --hair: rgba(156, 125, 51, .28);

  --f-display: "Cormorant Garamond", "Cormorant Garamond Fallback", Georgia, serif;
  --f-body: "EB Garamond", "EB Garamond Fallback", Georgia, serif;
  --f-label: "Alegreya Sans", "Alegreya Sans Fallback", Arial, sans-serif;

  --wrap: 1080px;
  --measure: 68ch;
  --nav-h: 62px;
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

body {
  margin: 0;
  font-family: var(--f-body);
  font-size: 1.125rem;
  line-height: 1.55;
  color: var(--nb);
  background: var(--paper);
  text-rendering: optimizeLegibility;
}

/* --- type ---------------------------------------------------------------- */

h1, h2, h3 {
  font-family: var(--f-display); font-weight: 600; color: var(--ink); line-height: 1.15; margin: 0 0 .4em;
  text-wrap: balance; font-variant-numeric: lining-nums;
}
h1 { font-size: clamp(2.1rem, 5.5vw, 3.3rem); letter-spacing: .01em; }
h2 { font-size: clamp(1.6rem, 3.6vw, 2.3rem); }
h3 { font-size: 1.3rem; }
p { margin: 0 0 1em; }
a { color: var(--ink); text-decoration-color: var(--gold); text-underline-offset: .18em; }
a:hover { color: var(--gold-text); }
strong { color: var(--ink); }
img { max-width: 100%; height: auto; }

/* Eyebrows keep their size and colour inside plates and cards too. */
.eyebrow, .plate .eyebrow, .card .eyebrow {
  font-family: var(--f-label); font-weight: 700; font-size: .72rem; line-height: 1.4;
  letter-spacing: .18em; text-transform: uppercase; color: var(--gold-text);
  margin: 0 0 .7em; text-align: left;
}
.eyebrow .ic { width: 1.3em; height: 1.3em; margin-right: .4em; vertical-align: -.32em; }

.lede { font-size: 1.25rem; color: var(--sepia); text-wrap: pretty; }
.measure { max-width: var(--measure); }

/* --- layout -------------------------------------------------------------- */

.wrap { width: min(100% - 2.5rem, var(--wrap)); margin-inline: auto; }
section { padding: clamp(2.6rem, 7vw, 4.6rem) 0; }
section + section { border-top: 1px solid rgba(156, 125, 51, .18); }
.plate { background: var(--parchment); border-top: none; }
.plate h1, .plate h2 { color: var(--ink); }
.plate p { color: var(--sepia); }
.band { background: var(--parchment-pale); }

:target { scroll-margin-top: calc(var(--nav-h) + 14px); }

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--ink); color: #fff; padding: .7rem 1.1rem; font-family: var(--f-label);
}
.skip:focus { left: .5rem; top: .5rem; }

:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 2px; }
.foot-main :focus-visible, .principle :focus-visible, .reader :focus-visible { outline-color: var(--gold-hi); }

/* --- navigation ---------------------------------------------------------- */

.nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: saturate(150%) blur(6px);
  border-bottom: 1px solid var(--hair);
}
.nav .wrap { display: flex; align-items: center; gap: 1.1rem; min-height: var(--nav-h); flex-wrap: wrap; }
.nav .brand {
  font-family: var(--f-display); font-weight: 700; font-size: 1.16rem;
  color: var(--ink); text-decoration: none; margin-right: auto; letter-spacing: .01em;
}
.nav .brand:hover { color: var(--ink); }
.nav a.nl {
  font-family: var(--f-label); font-size: .86rem; letter-spacing: .05em;
  color: var(--sepia); text-decoration: none; padding: .45rem 0;
}
.nav a.nl:hover, .nav a.nl[aria-current="page"] { color: var(--gold-text); }
.nav a.nl[aria-current="page"] { border-bottom: 2px solid var(--gold); }

/* Once the header wraps (small screens, or 200% zoom), it stops being pinned,
   so it never covers content or the diagnostic's progress bar. */
@media (max-width: 820px) {
  .nav { position: static; }
  :target { scroll-margin-top: 14px; }
}
@media (max-width: 600px) {
  .nav .wrap { gap: .25rem 1.1rem; padding: .6rem 0; }
  .nav .brand { flex-basis: 100%; }
  .nav a.nl[href*="#"] { display: none; }
  .nav .btn { min-height: 40px; padding: .45rem 1rem; }
}

/* --- buttons ------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 46px; padding: .6rem 1.35rem;
  font-family: var(--f-label); font-weight: 700; font-size: .93rem; letter-spacing: .03em;
  border-radius: 4px; border: 1px solid var(--ink); cursor: pointer;
  background: var(--ink); color: #fff; text-decoration: none;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.btn:hover { background: #16293c; color: #fff; }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.ghost:hover { background: var(--ink); color: #fff; }
.btn.gold { background: var(--gold-text); border-color: var(--gold-text); color: #fff; }
.btn.gold:hover { background: var(--ink); border-color: var(--ink); color: #fff; }
/* One look for anything not yet available: dashed, quiet, no hover change. */
.btn[disabled], .btn[disabled]:hover {
  background: transparent; color: var(--sepia); border: 1px dashed var(--parchment-deep); cursor: not-allowed;
}
.btn .ic { width: 1.15em; height: 1.15em; }
.btn-row { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1.4rem; }

/* --- icons --------------------------------------------------------------- */
/* Drawn in the line style of Figure 1.1. They take the colour of their text. */

.ic {
  display: inline-block; width: 1.1em; height: 1.1em; flex: 0 0 auto; vertical-align: -.18em;
  fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}

/* --- book components, ported from the print template --------------------- */

.glance, .blueprint {
  border: 1px solid var(--gold); background: var(--parchment-pale);
  border-radius: 6px; padding: 1rem 1.2rem; margin: 1.4rem 0;
}
.blueprint { border-left: 4px solid var(--gold); background: #F6F1E4; }
.glance .lbl, .blueprint .lbl {
  font-family: var(--f-label); font-weight: 700; font-size: .72rem;
  letter-spacing: .14em; text-transform: uppercase; color: var(--gold-text); margin: 0 0 .45em;
}
.glance p, .blueprint p { margin: .3em 0; font-size: 1rem; }

.principle {
  background: var(--ink); color: #fff; border-radius: 6px;
  padding: 1.3rem 1.5rem; margin: 1.8rem 0;
}
.principle .lbl {
  font-family: var(--f-label); font-weight: 700; font-size: .72rem;
  letter-spacing: .16em; text-transform: uppercase; color: var(--gold-hi); margin: 0 0 .5em;
}
.principle p { margin: 0; font-size: 1.2rem; font-style: italic; color: #fff; }

.vidura {
  border: 1px solid var(--oxblood); border-left: 4px solid var(--oxblood);
  background: #FBF3F1; border-radius: 6px; padding: 1rem 1.2rem; margin: 1.4rem 0;
}
.vidura .lbl {
  font-family: var(--f-label); font-weight: 700; font-size: .72rem;
  letter-spacing: .14em; text-transform: uppercase; color: var(--oxblood); margin: 0 0 .45em;
}
.vidura p { margin: 0; font-style: italic; color: var(--nb); }

/* Box labels are never italic, even where the box text is. */
.glance p.lbl, .blueprint p.lbl, .principle p.lbl, .vidura p.lbl { font-style: normal; }

.aphorism {
  text-align: center; font-style: italic; color: var(--ink);
  font-size: 1.2rem; line-height: 1.35;
  border-top: 1px solid var(--gold); border-bottom: 1px solid var(--gold);
  padding: .9rem 0; margin: 2rem auto; max-width: 46ch;
}

.illusion {
  background: var(--parchment); border-left: 3px solid var(--gold); color: var(--ink);
  font-family: var(--f-label); font-weight: 700; font-size: .82rem;
  letter-spacing: .07em; text-transform: uppercase;
  padding: .45rem .8rem; margin: 1.5rem 0 .6rem;
}

.figcap {
  font-family: var(--f-label); font-size: .7rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--gold-text); margin-top: .6rem;
}

.rule { border: 0; border-top: 1px solid var(--gold); margin: 2rem 0; opacity: .5; }

/* --- running text -------------------------------------------------------- */
/* Prose reads like the book: justified from tablet width up, with no automatic
   hyphenation. On desktop a longer passage can sit in two balanced columns;
   a paragraph never splits across them. Phones keep one left-aligned column. */

.prose p { margin: 0 0 1em; }
@media (min-width: 720px) {
  .prose p, .prose-single p:not(.lede) { text-align: justify; hyphens: none; text-wrap: pretty; }
}
@media (min-width: 980px) {
  .prose { columns: 2; column-gap: 3.2rem; column-rule: 1px solid rgba(156, 125, 51, .3); }
  .prose p { break-inside: avoid; }
}

/* Text beside a figure on desktop, stacked on smaller screens. Equal columns
   give justified lines enough room to set without wide gaps. */
.two-up { display: grid; gap: 2rem; align-items: start; }
@media (min-width: 980px) { .two-up { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 3.2rem; } }
.two-up .figure { margin: 0; }

/* --- the Five Levels ladder (Figure 1.1) --------------------------------- */

.figure { margin: 1.6rem 0; }
.figure .grp { border: 1px solid var(--gold); border-radius: 7px; background: var(--parchment); padding: .1rem .9rem; }
.figure .grp-top { background: var(--parchment); }
.figure .grp-bot { background: var(--parchment-pale); }
.figure .tier {
  display: flex; align-items: flex-start; gap: .7rem;
  padding: .7rem .1rem; border-bottom: 1px solid var(--hair);
}
.figure .grp .tier:last-child { border-bottom: none; }
.figure .tk { display: flex; align-items: center; gap: .4rem; flex: 0 0 auto; }
.figure .ti { width: 22px; height: 22px; flex: 0 0 22px; }
.figure .ti * { stroke: var(--ink); stroke-width: 1.4; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.figure .tn { font-family: var(--f-label); font-weight: 700; color: var(--gold-text); font-size: .95rem; font-variant-numeric: lining-nums; }
.figure .tt { font-size: 1rem; line-height: 1.4; }
.figure .tt b { color: var(--ink); }
.figure .tf {
  font-family: var(--f-label); font-size: .78rem; letter-spacing: .04em;
  color: var(--sepia); display: inline-block; margin-top: .15rem;
}
.figure .grouplabel {
  font-family: var(--f-label); font-weight: 700; font-size: .72rem;
  letter-spacing: .12em; text-transform: uppercase; color: var(--gold-text);
  padding: .35rem 0;
}
.figure .gl-bot { text-align: right; }
.figure .split {
  display: flex; align-items: center; gap: .7rem; padding: .55rem .1rem;
  font-family: var(--f-label); font-size: .74rem; letter-spacing: .06em;
  text-transform: uppercase; color: var(--sepia);
}
.figure .split .l { flex: 1; height: 1px; background: var(--gold); opacity: .6; }

/* --- cards --------------------------------------------------------------- */

.grid { display: grid; gap: 1.2rem; }
@media (min-width: 720px) {
  .grid.two { grid-template-columns: repeat(2, 1fr); }
  .grid.three { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 980px) {
  .grid.three-wide { grid-template-columns: repeat(3, 1fr); }
}

.card {
  border: 1px solid var(--hair); border-radius: 8px; background: var(--paper);
  padding: 1.2rem 1.3rem; display: flex; flex-direction: column;
}
.card h3 { margin-bottom: .3em; }
.card p { font-size: 1rem; color: var(--sepia); }
.card .foot { margin-top: auto; padding-top: .8rem; }
/* Chapter art runs edge to edge across the top of a card. */
.card picture.strip { display: block; margin: -1.2rem -1.3rem 1rem; border-radius: 8px 8px 0 0; overflow: hidden; }
.card picture.strip img { display: block; width: 100%; max-width: none; height: auto; aspect-ratio: 560 / 166; object-fit: cover; }

/* Tags: filled ink means available now; an outline means not yet or on request. */
.tag {
  display: inline-block; font-family: var(--f-label); font-weight: 700; font-size: .68rem;
  letter-spacing: .12em; text-transform: uppercase; color: var(--gold-text); background: var(--paper);
  border: 1px solid var(--hair); border-radius: 999px; padding: .18rem .6rem;
}
.tag.on { color: #fff; background: var(--ink); border-color: var(--ink); }

.facts { display: flex; flex-wrap: wrap; gap: .5rem; list-style: none; padding: 0; margin: 1.2rem 0 0; }
.facts li {
  font-family: var(--f-label); font-size: .8rem; letter-spacing: .04em; color: var(--sepia);
  border: 1px solid var(--parchment-deep); border-radius: 999px; padding: .25rem .8rem;
  background: rgba(255, 255, 255, .55); font-variant-numeric: lining-nums;
}

/* --- hero ---------------------------------------------------------------- */

.hero-plate { padding: clamp(2.2rem, 5vw, 3.6rem) 0; }
.hero { display: grid; gap: 2rem; align-items: center; }
@media (min-width: 860px) { .hero { grid-template-columns: minmax(0, 1fr) 400px; gap: 3.2rem; } }
.hero .cover { justify-self: center; width: 100%; max-width: 400px; }
.hero .cover picture {
  display: block; padding: 10px; background: var(--parchment-pale);
  border: 1px solid var(--gold); border-radius: 4px;
  box-shadow: 0 2px 6px rgba(40, 32, 20, .14), 0 22px 48px rgba(40, 32, 20, .2);
}
.hero .cover img { display: block; width: 100%; height: auto; border-radius: 2px; }

/* --- tables -------------------------------------------------------------- */

table { border-collapse: collapse; width: 100%; font-size: .98rem; margin: 1.2rem 0; }
th, td { border: 1px solid var(--hair); padding: .55rem .7rem; text-align: left; vertical-align: top; }
th {
  background: var(--parchment-pale); font-family: var(--f-label); font-weight: 700;
  font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--gold-text);
}
.scroller { overflow-x: auto; }

/* --- buy ----------------------------------------------------------------- */

.buy-wrap { display: grid; gap: 1.6rem; align-items: start; }
.buy-cover { display: none; }
@media (min-width: 900px) {
  .buy-wrap { grid-template-columns: 150px minmax(0, 1fr); gap: 2.2rem; }
  .buy-cover { display: block; }
  .buy-cover img { display: block; width: 150px; height: auto; border: 1px solid var(--gold); box-shadow: 0 10px 24px rgba(40, 32, 20, .18); }
}
.buy { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.buy .fallback { grid-column: 1 / -1; }
.buy .store {
  border: 1px solid var(--hair); border-radius: 8px; background: var(--paper);
  padding: 1rem; text-align: center; display: flex; flex-direction: column; gap: .6rem;
}
.buy .store .qr { width: 118px; height: 118px; margin: 0 auto; }
.buy .store .qr svg { width: 100%; height: 100%; display: block; }
.buy .store .name { font-family: var(--f-label); font-weight: 700; color: var(--ink); font-size: .95rem; }
.buy .store .meta { font-family: var(--f-label); font-size: .75rem; color: var(--sepia); letter-spacing: .04em; }
.buy .store .btn { width: 100%; margin-top: auto; }
/* A QR code cannot be scanned by the phone showing it. */
@media (max-width: 640px), (hover: none) and (pointer: coarse) {
  .buy .store .qr, .qr-hint { display: none; }
}

/* --- footer -------------------------------------------------------------- */

.foot-main { background: var(--ink); color: #cfd8e2; padding: 2.6rem 0 2rem; }
.foot-main a { color: #fff; text-decoration-color: var(--gold-hi); }
.foot-main a:hover { color: var(--gold-hi); }
.foot-main .cols { display: grid; gap: 1.6rem; }
@media (min-width: 720px) { .foot-main .cols { grid-template-columns: 2fr 1fr 1fr; } }
.foot-main .fh {
  font-family: var(--f-label); font-weight: 700; font-size: .72rem; letter-spacing: .14em;
  text-transform: uppercase; color: var(--gold-hi); margin: 0 0 .7em;
}
.foot-main .fdesc { color: #cfd8e2; font-size: .98rem; margin: 0; }
.foot-main ul { list-style: none; padding: 0; margin: 0; }
.foot-main li { margin: .35em 0; font-size: .95rem; }
.foot-main .fine {
  margin-top: 2rem; padding-top: 1.2rem; border-top: 1px solid rgba(255, 255, 255, .16);
  font-size: .84rem; color: #a8b4c2;
}

/* --- utilities ----------------------------------------------------------- */

.vh {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.centre { text-align: center; }

/* The hidden attribute must win over any layout display rule. */
[hidden] { display: none !important; }

/* A hyphenated word moves to the next line whole, so no line ends in a
   dangling hyphen that reads like a dash. Applied by EPIC.keepWordsWhole. */
.nw { white-space: nowrap; }

/* --- print --------------------------------------------------------------- */
/* Canvases and diagnostic results get printed for workshops: print the content,
   not the site around it, in dark text on white. */

@media print {
  .nav, .foot-main, .skip, .btn, .btn-row, .share, .buy .qr, .qr-hint, [data-form], .note { display: none !important; }
  body { font-size: 11pt; color: #000; background: #fff; }
  section { padding: .35cm 0; border: 0 !important; }
  .wrap { width: 100%; }
  .plate, .band, .card, .glance, .blueprint { background: #fff !important; }
  .principle, .reader { background: #fff !important; color: #000 !important; border: 1px solid #999; }
  .principle p, .principle .lbl, .reader p, .reader h2, .reader .eyebrow { color: #000 !important; }
  .card, .figure, .glance, .vidura, .principle, .tier, tr, .store, .parva { break-inside: avoid; }
  h1, h2, h3, .pg { break-after: avoid; }
  a { color: #000; text-decoration: none; }
}
