/* Principles: the index pages and one page per principle, all written by build.py.
   Builds on styles.css + teardowns.css. */

.pr-hero-inner { max-width: 1112px; margin: 0 auto; padding: 48px 40px 44px; }
.pr-hero .td-hero-title { max-width: 860px; }
.pr-hero-sub { max-width: 640px; margin: 18px 0 0; font-size: 18px; line-height: 1.5; color: rgb(255 255 255 / 85%); }
.pr-crumbs ol { display: flex; flex-wrap: wrap; gap: 4px 0; margin: 0 0 22px; padding: 0; list-style: none; font-size: 14px; font-weight: 500; }
.pr-crumbs li { color: rgb(255 255 255 / 75%); }
.pr-crumbs li + li::before { content: "/"; margin: 0 9px; color: rgb(255 255 255 / 45%); }
.pr-crumbs a { color: var(--lime); text-decoration: none; }
.pr-crumbs a:hover { text-decoration: underline; text-underline-offset: 3px; }
.pr-kind { margin: 0 0 10px; font-size: 13px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--lime); }

.pr-wrap { padding-top: 40px; }

/* Index */
.pr-group { margin-bottom: 48px; }
.pr-group-title {
  margin: 0 0 18px;
  font-family: var(--serif);
  font-variation-settings: "opsz" 36;
  font-weight: 450;
  font-size: 28px;
  letter-spacing: -0.005em;
}
.pr-group-title a { color: inherit; text-decoration: none; }
.pr-group-title a:hover { color: var(--accent); }
.pr-group-title span { margin-left: 6px; font-family: var(--sans); font-size: 14px; font-weight: 500; color: var(--text-faint); }
.pr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.pr-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px 18px 16px;
  overflow: hidden;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--ink);
  text-decoration: none;
  transition: border-color 0.15s, transform 0.2s var(--ease), box-shadow 0.2s;
}
.pr-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 8px 24px rgb(36 67 214 / 10%); }
.pr-card-art { display: block; margin: -18px -18px 6px; border-bottom: 1px solid var(--border); background: var(--card); }
.pr-card-art svg { display: block; width: 100%; height: auto; }
.pr-card-name { font-size: 17px; font-weight: 600; }
.pr-card-sum { flex: 1; font-size: 14px; line-height: 1.5; color: var(--text-soft); }
.pr-card-meta { font-size: 12px; font-weight: 500; color: var(--accent); }

/* Principle page */
.pr-cols { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 56px; align-items: start; }
.pr-article { max-width: 680px; min-width: 0; }
.pr-article > p { margin: 0 0 18px; font-size: 18px; line-height: 1.6; }
.pr-article h2, .pr-sources h2 {
  margin: 36px 0 14px;
  font-family: var(--serif);
  font-variation-settings: "opsz" 36;
  font-weight: 450;
  font-size: 24px;
  letter-spacing: -0.005em;
}
.pr-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.pr-list li { position: relative; padding-left: 26px; font-size: 16px; line-height: 1.55; }
.pr-list li::before { content: ""; position: absolute; left: 2px; top: 0.5em; width: 9px; height: 9px; border-radius: 50%; background: var(--good); }
.pr-list-dont li::before { background: transparent; box-shadow: inset 0 0 0 2px var(--bad); }
.pr-related { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
.pr-related a {
  padding: 6px 12px;
  border-radius: 8px;
  background: var(--sand);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
}
.pr-related a:hover { background: var(--accent); color: #fff; }

.pr-sources { position: sticky; top: 24px; padding: 4px 24px 22px; border-radius: 16px; background: var(--card); border: 1px solid var(--border); }
.pr-sources h2 { margin-top: 20px; }
.pr-sources ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 18px; }
.pr-sources li { display: flex; flex-direction: column; gap: 4px; }
.pr-sources a { font-size: 15px; font-weight: 600; line-height: 1.35; color: var(--link); text-decoration: none; }
.pr-sources a:hover { text-decoration: underline; text-underline-offset: 3px; }
.pr-sources a span { font-size: 0.85em; }
.pr-src-by { font-size: 13px; color: var(--text-faint); }
.pr-src-find { font-size: 14px; line-height: 1.5; color: var(--text-soft); }

.pr-examples { margin-top: 64px; padding-top: 40px; border-top: 2px solid var(--ink); }
.pr-ex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.pr-ex {
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--ink);
  text-decoration: none;
  transition: border-color 0.15s, transform 0.2s var(--ease);
}
.pr-ex:hover { border-color: var(--accent); transform: translateY(-2px); }
.pr-ex-shot {
  position: relative;
  display: block;
  width: 280px;
  max-width: 100%;
  height: 168px;
  margin: 0 auto;
  overflow: hidden;
}
/* build.py sizes and places the screenshot so the note's box sits in the middle of the frame. */
.pr-ex-shot img { position: absolute; max-width: none; }
.pr-ex-frame { display: block; background: var(--sand); }
.pr-ex-box { position: absolute; border: 2px solid var(--good); border-radius: 6px; }
.pr-ex-bad .pr-ex-box { border-color: var(--bad); border-style: dashed; }
.pr-ex-body { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px 16px; border-top: 1px solid var(--border); }
.pr-ex-co { font-size: 12px; font-weight: 600; color: var(--text-faint); }
.pr-ex-title { font-size: 15px; font-weight: 600; }
.pr-ex-note { font-size: 14px; line-height: 1.5; color: var(--text-soft); }
.pr-more { margin-top: 56px; }

@media (max-width: 960px) {
  .pr-cols { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .pr-sources { position: static; }
  .pr-hero-inner { padding: 40px 32px 36px; }
}
@media (max-width: 600px) {
  .pr-hero-inner { padding: 30px 20px 26px; }
  .pr-hero-sub { font-size: 16px; }
  .pr-article > p { font-size: 17px; }
}

/* ── Illustrations: inline SVGs in images/principles/<slug>.svg ──
   build.py inlines each one into its page. Colors come only from these classes, so every figure
   shares the palette. */
.pr-fig { margin: 0 0 32px; }
.pr-fig-art { border-radius: 16px; background: var(--card); border: 1px solid var(--border); overflow: hidden; }
.pr-fig-art svg { display: block; width: 100%; height: auto; }
@media (max-width: 600px) {
  /* Keep labels readable on phones: the figure keeps a minimum width and scrolls sideways. */
  .pr-fig-art { overflow-x: auto; }
  .pr-fig-art svg { min-width: 560px; }
  .pr-fig figcaption { flex-wrap: wrap; gap: 6px 16px; }
  .pr-fig figcaption::before { content: "Swipe the picture sideways to see all of it →"; flex-basis: 100%; font-size: 12px; font-weight: 600; color: var(--accent); }
}
.pr-fig figcaption { margin-top: 10px; font-size: 14px; line-height: 1.5; color: var(--text-soft); }
.pr-fig svg text, .pr-card-art svg text { font-family: var(--sans); fill: var(--ink); font-size: 14px; }
.pr-fig svg .t-sm, .pr-card-art svg .t-sm { font-size: 13px; fill: var(--text-faint); }
.pr-fig svg .t-md, .pr-card-art svg .t-md { font-size: 15px; font-weight: 600; }
.pr-fig svg .t-lg, .pr-card-art svg .t-lg { font-size: 20px; font-weight: 600; }
.pr-fig svg .t-serif, .pr-card-art svg .t-serif { font-family: var(--serif); font-variation-settings: "opsz" 36; font-weight: 450; font-size: 26px; }
.pr-fig svg .t-big, .pr-card-art svg .t-big { font-family: var(--serif); font-variation-settings: "opsz" 36; font-weight: 450; font-size: 38px; letter-spacing: -0.01em; }
.pr-fig svg .t-kick, .pr-card-art svg .t-kick { font-size: 12px; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase; fill: var(--text-faint); }
.pr-fig svg .t-b, .pr-card-art svg .t-b { font-weight: 600; }
.pr-fig svg .t-soft, .pr-card-art svg .t-soft { fill: var(--text-soft); }
.pr-fig svg .t-good, .pr-card-art svg .t-good { fill: var(--good); }
.pr-fig svg .t-bad, .pr-card-art svg .t-bad { fill: var(--bad); }
.pr-fig svg .t-white, .pr-card-art svg .t-white { fill: #fff; }
.pr-fig svg .t-mid, .pr-card-art svg .t-mid { text-anchor: middle; }
.pr-fig svg .t-end, .pr-card-art svg .t-end { text-anchor: end; }
.pr-fig svg .f-ink, .pr-card-art svg .f-ink { fill: var(--ink); }
.pr-fig svg .f-soft, .pr-card-art svg .f-soft { fill: var(--text-soft); }
.pr-fig svg .f-faint, .pr-card-art svg .f-faint { fill: var(--text-faint); }
.pr-fig svg .f-good, .pr-card-art svg .f-good { fill: var(--good); }
.pr-fig svg .f-good-soft, .pr-card-art svg .f-good-soft { fill: var(--accent-soft); }
.pr-fig svg .f-bad, .pr-card-art svg .f-bad { fill: var(--bad); }
.pr-fig svg .f-bad-soft, .pr-card-art svg .f-bad-soft { fill: #fbe3de; }
.pr-fig svg .f-lime, .pr-card-art svg .f-lime { fill: var(--lime); }
.pr-fig svg .f-sand, .pr-card-art svg .f-sand { fill: var(--sand); }
.pr-fig svg .f-card, .pr-card-art svg .f-card { fill: var(--card); }
.pr-fig svg .f-bg, .pr-card-art svg .f-bg { fill: var(--bg); }
.pr-fig svg .f-white, .pr-card-art svg .f-white { fill: #fff; }
.pr-fig svg .f-none, .pr-card-art svg .f-none { fill: none; }
.pr-fig svg .s-ink, .pr-card-art svg .s-ink { stroke: var(--ink); }
.pr-fig svg .s-good, .pr-card-art svg .s-good { stroke: var(--good); }
.pr-fig svg .s-bad, .pr-card-art svg .s-bad { stroke: var(--bad); }
.pr-fig svg .s-rule, .pr-card-art svg .s-rule { stroke: var(--border); }
.pr-fig svg .s-faint, .pr-card-art svg .s-faint { stroke: var(--text-faint); }
.pr-fig svg .s-lime, .pr-card-art svg .s-lime { stroke: var(--lime); }
.pr-fig svg .s-white, .pr-card-art svg .s-white { stroke: #fff; }
.pr-fig svg .dash, .pr-card-art svg .dash { stroke-dasharray: 6 5; }

/* Motion: a figure plays once when it scrolls into view (js/principles.js holds it until then and
   wires the Replay button). In the SVG: one of a-fade / a-pop / a-grow-y / a-grow-x / a-draw, plus
   d1..d9 for the step it appears on. Individual translate/scale properties are used so a transform
   attribute on the same element keeps working. */
@keyframes pr-fade { from { opacity: 0; translate: 0 10px; } }
@keyframes pr-pop { from { opacity: 0; scale: 0.6; } }
@keyframes pr-grow-y { from { scale: 1 0; } }
@keyframes pr-grow-x { from { scale: 0 1; } }
@keyframes pr-draw { from { stroke-dashoffset: 1; } }
@media (prefers-reduced-motion: no-preference) {
  .pr-fig svg .a-fade { animation: pr-fade 0.55s var(--ease) backwards; }
  .pr-fig svg .a-pop { transform-box: fill-box; transform-origin: center; animation: pr-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) backwards; }
  .pr-fig svg .a-grow-y { transform-box: fill-box; transform-origin: 50% 100%; animation: pr-grow-y 0.8s var(--ease) backwards; }
  .pr-fig svg .a-grow-x { transform-box: fill-box; transform-origin: 0 50%; animation: pr-grow-x 0.8s var(--ease) backwards; }
  /* a-draw needs pathLength="1" on the element and a solid (not .dash) stroke. */
  .pr-fig svg .a-draw { stroke-dasharray: 1; animation: pr-draw 0.9s ease-in-out backwards; }
  .pr-fig svg .d1 { animation-delay: 0.35s; }
  .pr-fig svg .d2 { animation-delay: 0.7s; }
  .pr-fig svg .d3 { animation-delay: 1.05s; }
  .pr-fig svg .d4 { animation-delay: 1.4s; }
  .pr-fig svg .d5 { animation-delay: 1.75s; }
  .pr-fig svg .d6 { animation-delay: 2.1s; }
  .pr-fig svg .d7 { animation-delay: 2.45s; }
  .pr-fig svg .d8 { animation-delay: 2.8s; }
  .pr-fig svg .d9 { animation-delay: 3.15s; }
  /* With JS the figure waits until it is on screen; without JS it plays on load. */
  .js .pr-fig:not(.is-seen) svg * { animation-play-state: paused; }
}
.pr-fig figcaption { display: flex; align-items: flex-start; gap: 16px; }
.pr-fig figcaption span { flex: 1; }
.pr-replay {
  flex: none;
  display: none;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text-soft);
  font: 500 12px var(--sans);
  cursor: pointer;
}
.pr-replay:hover { border-color: var(--accent); color: var(--accent); }
.pr-replay:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pr-replay svg { width: 12px; height: 12px; }
@media (prefers-reduced-motion: no-preference) { .js .pr-replay { display: inline-flex; } }
