/* TAOM Mods - journal style. Colours are tokens; dark mode is a candle-lit page. */
@import url("fonts/fonts.css");

:root {
  --desk: #6e3d2b;
  --paper: #f1e4c6;
  --paper-edge: #dcc69c;
  --ink: #3a2816;
  --ink-soft: #5f4730;
  --rule: #7b5b39;
  --seal: #8a2b1b;
  --seal-text: #f6e9cc;
  --accent: #8a2b1b;
  --link: #74301a;
  --glow: rgba(120, 80, 30, 0.10);
  --noise-alpha: .10;
  --shadow: 0 1px 2px rgba(60, 40, 20, .25), 0 12px 40px rgba(60, 40, 20, .25);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --desk: #4a2a1e;
    --paper: #2a1f15;
    --paper-edge: #1a120b;
    --ink: #ecd8ad;
    --ink-soft: #c7ad85;
    --rule: #a7824f;
    --seal: #a9432a;
    --seal-text: #f8e6c2;
    --accent: #e48a5f;
    --link: #f0bd7c;
    --glow: rgba(255, 170, 80, .10);
    --noise-alpha: .16;
    --shadow: 0 0 0 1px rgba(0,0,0,.5), 0 16px 60px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --desk: #4a2a1e; --paper: #2a1f15; --paper-edge: #1a120b; --ink: #ecd8ad; --ink-soft: #c7ad85;
  --rule: #a7824f; --seal: #a9432a; --seal-text: #f8e6c2; --accent: #e48a5f; --link: #f0bd7c; --glow: rgba(255, 170, 80, .10);
  --noise-alpha: .16; --shadow: 0 0 0 1px rgba(0,0,0,.5), 0 16px 60px rgba(0,0,0,.6); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  /* brown leather: scratches, embossed grain, mottling and a soft sheen, multiplied over the base colour */
  background-color: var(--desk);
  background-image:
    radial-gradient(ellipse at center, transparent 35%, rgba(0, 0, 0, .5) 100%),
    radial-gradient(ellipse at 45% 30%, rgba(255, 220, 180, .10), transparent 60%),
    url("leather-scratches.svg"),
    radial-gradient(ellipse 40% 30% at 22% 70%, rgba(0, 0, 0, .22), transparent 70%),
    radial-gradient(ellipse 35% 28% at 78% 25%, rgba(0, 0, 0, .18), transparent 70%),
    radial-gradient(ellipse 30% 25% at 70% 80%, rgba(255, 200, 160, .06), transparent 70%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='250' height='250'><filter id='g'><feTurbulence type='turbulence' baseFrequency='.6' numOctaves='2' seed='3' stitchTiles='stitch'/><feDiffuseLighting lighting-color='white' surfaceScale='2.6' diffuseConstant='1.15'><feDistantLight azimuth='235' elevation='58'/></feDiffuseLighting></filter><rect width='100%' height='100%' filter='url(%23g)'/></svg>");
  background-blend-mode: normal, normal, normal, normal, normal, normal, multiply;
  background-attachment: fixed, fixed, scroll, fixed, fixed, fixed, scroll;
  color: var(--ink);
  font-family: "EB Garamond", Garamond, "Times New Roman", serif;
  font-size: 1.13rem;
  line-height: 1.6;
  padding: 32px 16px 48px;
}

/* stitched seam around the cover edge */
body::before {
  content: ""; position: fixed; inset: 12px; z-index: 0; pointer-events: none;
  border: 2px dashed rgba(226, 196, 146, .62); border-radius: 8px;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, .28), inset 0 0 0 2px rgba(0, 0, 0, .28);
}
.page {
  z-index: 1;
  position: relative;
  max-width: 880px;
  margin: 0 auto;
  padding: 56px 64px 40px;
  background-color: var(--paper);
  background-image:
    radial-gradient(ellipse at 20% 15%, rgba(255,255,255,.18), transparent 55%),
    radial-gradient(ellipse at 85% 70%, rgba(120,80,30,.10), transparent 50%),
    radial-gradient(ellipse at center, transparent 55%, var(--paper-edge) 100%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='300' height='300'><filter id='p'><feTurbulence type='fractalNoise' baseFrequency='.65' numOctaves='4' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .35 0 0 0 0 .24 0 0 0 0 .1 0 0 0 .45 0'/></filter><rect width='100%' height='100%' filter='url(%23p)'/></svg>");
  box-shadow: var(--shadow);
  border-radius: 3px;
  outline: 2px dashed rgba(236, 214, 170, .6);
  outline-offset: 12px;
}
/* hand-ruled double frame */
.page::before {
  content: "";
  position: absolute;
  inset: 14px;
  border: 1.5px solid var(--rule);
  outline: 1px solid var(--rule);
  outline-offset: 4px;
  opacity: .55;
  border-radius: 2px;
  pointer-events: none;
}
.corner { position: absolute; width: 46px; height: 46px; color: var(--rule); opacity: .8; pointer-events: none; }
.corner.tl { top: 8px; left: 8px; }
.corner.tr { top: 8px; right: 8px; transform: scaleX(-1); }
.corner.bl { bottom: 8px; left: 8px; transform: scaleY(-1); }
.corner.br { bottom: 8px; right: 8px; transform: scale(-1, -1); }

/* masthead */
.masthead { text-align: center; position: relative; }
.compass { position: absolute; right: -6px; top: -14px; width: 74px; height: 74px; color: var(--rule); opacity: .55; }
.seal { width: 112px; height: 112px; display: block; margin: 0 auto 6px; filter: drop-shadow(0 2px 2px rgba(0,0,0,.3)); }
h1 {
  font-family: "IM Fell English SC", "IM Fell English", serif;
  font-weight: 400;
  font-size: clamp(2.6rem, 8vw, 4.2rem);
  letter-spacing: .04em;
  line-height: 1;
  margin: 0;
}
.subtitle { font-family: "IM Fell English", serif; font-style: italic; color: var(--ink-soft); font-size: 1.2rem; margin: .5rem 0 0; }
nav { margin: 1.2rem 0 0; font-family: "IM Fell English SC", serif; font-size: 1.05rem; letter-spacing: .04em; }
nav a { white-space: nowrap; }
nav .sep { color: var(--rule); margin: 0 .5em; }

.rule { display: block; width: 100%; max-width: 560px; height: 24px; margin: 1.6rem auto; color: var(--rule); }

/* chapters */
section { margin: 0; scroll-margin-top: 16px; }
.kicker {
  font-family: "IM Fell English SC", serif; color: var(--accent);
  letter-spacing: .18em; font-size: .95rem; text-align: center; margin: 0;
}
h2 {
  font-family: "IM Fell English", serif; font-weight: 400;
  font-size: clamp(1.8rem, 5vw, 2.4rem); line-height: 1.15;
  text-align: center; margin: .2rem 0 .3rem;
}
.meta { text-align: center; font-style: italic; color: var(--ink-soft); margin: 0 0 1.2rem; }
h3 {
  font-family: "IM Fell English SC", serif; font-weight: 400; font-size: 1.25rem;
  letter-spacing: .04em; margin: 1.6rem 0 .3rem; color: var(--ink);
}
h3::before { content: "\2766"; color: var(--accent); margin-right: .4em; font-family: "EB Garamond", serif; }
p { margin: .6rem 0; }
.lead::first-letter {
  font-family: "IM Fell English SC", serif; float: left; font-size: 3.6rem; line-height: .82;
  padding: .3rem .5rem 0 0; color: var(--accent);
}
ul, ol { padding-left: 1.4rem; margin: .4rem 0; }
li { margin: .2rem 0; }
li::marker { color: var(--rule); }
code { font-family: Consolas, "Courier New", monospace; font-size: .88em; background: rgba(120,80,30,.12); padding: .05em .3em; border-radius: 2px; overflow-wrap: anywhere; }
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
a:focus-visible, summary:focus-visible { outline: 2px dashed var(--seal); outline-offset: 3px; }

.note {
  border-left: 3px double var(--rule); padding: .3rem 0 .3rem 1rem; margin: 1rem 0;
  font-style: italic; color: var(--ink-soft);
}
.note strong { font-style: normal; font-family: "IM Fell English SC", serif; font-weight: 400; color: var(--ink); }

details { margin: 1rem 0; border-top: 1px dashed var(--rule); border-bottom: 1px dashed var(--rule); padding: .4rem 0; }
summary { cursor: pointer; font-family: "IM Fell English SC", serif; font-size: 1.1rem; letter-spacing: .03em; list-style: none; }
summary::-webkit-details-marker { display: none; }
summary::before { content: "\25B8"; display: inline-block; width: 1.1em; color: var(--accent); transition: transform .15s; }
details[open] summary::before { transform: rotate(90deg); }
details > *:not(summary) { font-size: 1.02rem; }

/* buttons, like stamped labels */
.actions { display: flex; flex-wrap: wrap; gap: .7rem; justify-content: center; margin: 1.6rem 0 .6rem; }
.btn {
  display: inline-flex; align-items: center; gap: .5em;
  font-family: "IM Fell English SC", serif; font-size: 1.1rem; letter-spacing: .04em;
  text-decoration: none; color: var(--ink);
  padding: .5rem 1.1rem .45rem; min-height: 44px;
  border: 1.5px solid var(--ink); border-radius: 3px;
  background: rgba(120, 80, 30, .07);
  box-shadow: inset 0 0 0 3px var(--paper), inset 0 0 0 4px var(--rule);
}
.btn:hover { background: rgba(120, 80, 30, .16); text-decoration: none; }
.btn svg { width: 1.05em; height: 1.05em; flex: none; }
.btn.primary {
  background: var(--seal); color: var(--seal-text); border-color: var(--seal);
  box-shadow: inset 0 0 0 3px var(--seal), inset 0 0 0 4px rgba(246,233,204,.55), 0 2px 4px rgba(0,0,0,.25);
}
.btn.primary:hover { filter: brightness(1.08); background: var(--seal); }
.small { font-size: .95rem; color: var(--ink-soft); text-align: center; }

/* pictures as section dividers, with a torn top and bottom edge */
figure.plate { margin: 2.2rem -64px; }
figure.plate img {
  display: block; width: 100%; height: auto; aspect-ratio: 12 / 5;
  object-fit: cover; background: var(--paper-edge);
  clip-path: polygon(0 2%, 4% .6%, 9% 1.8%, 15% .3%, 22% 1.5%, 28% .5%, 35% 1.9%, 41% .7%, 48% 1.6%, 55% .2%, 61% 1.4%, 68% .6%, 74% 1.9%, 81% .4%, 87% 1.5%, 93% .5%, 100% 1.7%,
    100% 98.2%, 95% 99.6%, 89% 98.4%, 83% 99.7%, 76% 98.6%, 70% 99.5%, 63% 98.1%, 57% 99.4%, 50% 98.5%, 44% 99.8%, 37% 98.4%, 31% 99.4%, 24% 98.2%, 18% 99.6%, 11% 98.5%, 5% 99.5%, 0 98.3%);
  filter: sepia(.12) contrast(1.02);
}
figure.plate figcaption { text-align: center; font-style: italic; font-size: .95rem; color: var(--ink-soft); margin-top: .4rem; padding: 0 16px; }

/* GitHub cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .9rem; margin: 1rem 0 .5rem; }
.card {
  display: flex; flex-direction: column; gap: .25rem; padding: .9rem 1rem; min-height: 44px;
  text-decoration: none; color: var(--ink); border: 1.5px solid var(--rule); border-radius: 3px;
  background: rgba(120, 80, 30, .07); box-shadow: inset 0 0 0 3px var(--paper), inset 0 0 0 4px var(--rule);
}
.card:hover { background: rgba(120, 80, 30, .16); }
.card-title { font-family: "IM Fell English SC", serif; font-size: 1.12rem; letter-spacing: .03em; }
.card-sub { font-size: .9rem; color: var(--ink-soft); overflow-wrap: anywhere; }

/* credits */
.credits { font-size: 1rem; }
.credits h3 { font-size: 1.1rem; }
.credits ul { padding-left: 1.2rem; }
footer { text-align: center; font-size: .95rem; color: var(--ink-soft); margin-top: 1.6rem; }
footer p { margin: .35rem 0; }

@media (max-width: 640px) {
  body { padding: 18px 10px; font-size: 1.06rem; }
  .page { outline-offset: 6px; }
  body::before { inset: 4px; }
  .page { padding: 40px 22px 28px; border-radius: 0; }
  .page::before { inset: 8px; }
  .corner { width: 32px; height: 32px; }
  .corner.tl, .corner.tr { top: 3px; } .corner.bl, .corner.br { bottom: 3px; }
  .corner.tl, .corner.bl { left: 3px; } .corner.tr, .corner.br { right: 3px; }
  .compass { display: none; }
  figure.plate { margin: 1.8rem -22px; }
  .btn { width: 100%; justify-content: center; }
  .lead::first-letter { font-size: 3rem; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } summary::before { transition: none; } }
@media print { body { background: #fff; padding: 0; } .page { box-shadow: none; } figure.plate img { filter: none; } }

.tally { margin-top: -.2rem; }
.tally-note { font-size: .88rem; }
[hidden] { display: none !important; }
