/* ==========================================================================
   PoE2 Build Crafting — shared course stylesheet
   Used by every lesson and reference document. Tufte-influenced:
   generous measure, real typographic scale, sidenotes, print-clean.
   ========================================================================== */

:root {
  --ink:            #16130f;
  --ink-soft:       #4a443c;
  --ink-faint:      #857c70;
  --paper:          #fbf9f4;
  --paper-raised:   #f3efe6;
  --rule:           #ddd6c8;
  --rule-soft:      #e9e3d6;

  --accent:         #8a3324;   /* iron oxide — headings, emphasis */
  --accent-soft:    #b8674f;
  --gain:           #2f6b45;   /* correct / gain */
  --loss:           #9c3a2e;   /* wrong / loss */
  --flag:           #8a6d1f;   /* volatile / caution */

  --measure:        34rem;
  --serif:          "Iowan Old Style", "Palatino Linotype", Palatino, Charter, Georgia, serif;
  --sans:           "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, sans-serif;
  --mono:           "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink:          #e8e3d9;
    --ink-soft:     #b3aa9c;
    --ink-faint:    #837a6c;
    --paper:        #16150f;
    --paper-raised: #201e16;
    --rule:         #38342a;
    --rule-soft:    #2a2720;
    --accent:       #d98166;
    --accent-soft:  #b8674f;
    --gain:         #6fbc8e;
    --loss:         #e08a7a;
    --flag:         #d4b055;
  }
}

/* ---------- base ---------- */

* { box-sizing: border-box; }

html { font-size: 17px; }

body {
  margin: 0;
  padding: 0 2rem 8rem;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.wrap { max-width: var(--measure); margin: 0 auto; }

/* wide elements break the measure deliberately */
.wide { max-width: 46rem; margin-left: auto; margin-right: auto; }

/* ---------- masthead ---------- */

.masthead {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 4rem 0 0;
}

.eyebrow {
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 0.9rem;
}

h1 {
  font-size: 2.5rem;
  line-height: 1.1;
  font-weight: 400;
  letter-spacing: -0.02em;
  margin: 0 0 0.6rem;
}

.standfirst {
  font-size: 1.16rem;
  line-height: 1.5;
  color: var(--ink-soft);
  font-style: italic;
  margin: 0 0 1.4rem;
}

.meta {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--ink-faint);
  padding-bottom: 2.2rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 2.6rem;
}
.meta span + span::before { content: " · "; }

h2 {
  font-family: var(--sans);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 3.4rem 0 1rem;
}

h3 {
  font-size: 1.28rem;
  font-weight: 600;
  line-height: 1.3;
  margin: 2.2rem 0 0.6rem;
}

p { margin: 0 0 1.15rem; }

a {
  color: inherit;
  text-decoration-color: var(--accent-soft);
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
}
a:hover { color: var(--accent); }

strong { font-weight: 600; }

code, .num {
  font-family: var(--mono);
  font-size: 0.87em;
  background: var(--paper-raised);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

ul, ol { margin: 0 0 1.15rem; padding-left: 1.3rem; }
li { margin-bottom: 0.45rem; }
li::marker { color: var(--ink-faint); }

hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 3rem 0;
}

/* ---------- sidenote ---------- */

.sidenote {
  font-family: var(--sans);
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--ink-soft);
  border-left: 2px solid var(--rule);
  padding-left: 0.9rem;
  margin: 1.5rem 0;
}

/* ---------- callouts ---------- */

.callout {
  background: var(--paper-raised);
  border-left: 3px solid var(--accent);
  padding: 1.1rem 1.3rem;
  margin: 1.8rem 0;
  border-radius: 0 4px 4px 0;
}
.callout > :last-child { margin-bottom: 0; }
.callout-label {
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  display: block;
  margin-bottom: 0.5rem;
}
.callout.volatile { border-left-color: var(--flag); }
.callout.volatile .callout-label { color: var(--flag); }

/* the one idea the lesson exists to deliver */
.keystone {
  border: 1px solid var(--accent);
  border-left-width: 3px;
  background: transparent;
  padding: 1.3rem 1.4rem;
  margin: 2rem 0;
  border-radius: 0 4px 4px 0;
}
.keystone > :last-child { margin-bottom: 0; }
.keystone p { font-size: 1.08rem; }

/* ---------- formula display ---------- */

.formula {
  font-family: var(--mono);
  font-size: 0.9rem;
  line-height: 2.1;
  background: var(--paper-raised);
  border: 1px solid var(--rule-soft);
  border-radius: 5px;
  padding: 1.2rem 1.4rem;
  margin: 1.8rem 0;
  overflow-x: auto;
}
.formula .term { color: var(--accent); font-weight: 600; }
.formula .cmt  { color: var(--ink-faint); }

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

.tbl-scroll { overflow-x: auto; margin: 1.8rem 0; }

table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: 0.86rem;
}
th {
  text-align: left;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  border-bottom: 1px solid var(--rule);
  padding: 0 0.8rem 0.5rem 0;
  white-space: nowrap;
}
td {
  padding: 0.55rem 0.8rem 0.55rem 0;
  border-bottom: 1px solid var(--rule-soft);
  vertical-align: top;
}
tbody tr:last-child td { border-bottom: 0; }
td.n { font-family: var(--mono); white-space: nowrap; }
.gain { color: var(--gain); font-weight: 600; }
.loss { color: var(--loss); font-weight: 600; }

/* ---------- exercise block ---------- */

.exercise {
  border: 1px solid var(--rule);
  border-radius: 5px;
  padding: 1.3rem 1.4rem;
  margin: 2rem 0;
  background: var(--paper-raised);
}
.exercise-label {
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  display: block;
  margin-bottom: 0.7rem;
}
.exercise > :last-child { margin-bottom: 0; }

/* ---------- character sheet (stat block) ---------- */

.sheet {
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.85;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 5px;
  padding: 1.1rem 1.3rem;
  margin: 1.4rem 0;
}
.sheet .row { display: flex; justify-content: space-between; gap: 1.5rem; }
.sheet .row span:last-child { color: var(--ink-soft); white-space: nowrap; }
.sheet .hd {
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0.9rem 0 0.3rem;
}
.sheet .hd:first-child { margin-top: 0; }

/* ---------- item card ---------- */

.items { display: grid; gap: 0.9rem; margin: 1.6rem 0; }
@media (min-width: 40rem) { .items.two-up { grid-template-columns: 1fr 1fr; } }

.item {
  font-family: var(--sans);
  font-size: 0.84rem;
  line-height: 1.5;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 5px;
  padding: 0.9rem 1.05rem;
}
.item-name {
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--accent);
  margin-bottom: 0.15rem;
}
.item-base {
  font-size: 0.75rem;
  color: var(--ink-faint);
  margin-bottom: 0.6rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--rule-soft);
}
.item-mods { list-style: none; padding: 0; margin: 0; }
.item-mods li {
  margin-bottom: 0.3rem;
  padding-left: 0;
  color: var(--ink-soft);
}
.item-mods li:last-child { margin-bottom: 0; }
.item-mods li.implicit { font-style: italic; color: var(--ink-faint); }

/* ---------- tag row ---------- */

.tags { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0 0 0.9rem; }
.tag {
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0.2rem 0.5rem;
  color: var(--ink-soft);
}
.tag.key { border-color: var(--accent); color: var(--accent); }

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

.footer {
  max-width: var(--measure);
  margin: 4rem auto 0;
  padding-top: 2rem;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--ink-soft);
}
.footer h2 { margin-top: 0; }
.footer ul { list-style: none; padding: 0; }
.footer li { margin-bottom: 0.6rem; }

.ask {
  font-family: var(--sans);
  font-size: 0.85rem;
  background: var(--paper-raised);
  border-radius: 5px;
  padding: 1rem 1.2rem;
  margin: 2.4rem 0 0;
  color: var(--ink-soft);
}
.ask strong { color: var(--ink); }

/* ---------- print ---------- */

@media print {
  :root {
    --ink: #000; --ink-soft: #333; --ink-faint: #666;
    --paper: #fff; --paper-raised: #f6f6f6;
    --rule: #bbb; --rule-soft: #ddd; --accent: #000; --accent-soft: #555;
  }
  html { font-size: 11pt; }
  body { padding: 0; }
  .quiz-check, .ask { display: none; }
  .quiz-feedback { display: block !important; }
  .exercise, .callout, .keystone, .sheet, .formula { break-inside: avoid; }
  h2, h3 { break-after: avoid; }
  a { text-decoration: none; }
  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.75em;
    color: #666;
  }
}

@media (max-width: 34rem) {
  html { font-size: 16px; }
  body { padding: 0 1.1rem 5rem; }
  h1 { font-size: 1.9rem; }
}
