/* Articles del quadern: es carrega només a les pàgines d'articles (es/articulos). Reutilitza els tokens de /styles.css.
   Referències: rough-stuff/rough (hachure), jwilber/roughViz i timqian/chart.xkcd (gràfics dibuixats a mà),
   reinterpretades amb CSS i SVG inline, sense dependències JS. */

.page-article { --prose: 68ch; --crawl: var(--blue); --index: var(--mint); --serve: var(--yellow); }

/* ---------- Hero ---------- */
.article-hero { min-height: 0; padding-block: clamp(3.5rem, 7vw, 6rem) clamp(2rem, 4vw, 3rem); position: relative; }
.article-hero h1 { max-width: 20ch; font-size: clamp(2.5rem, 5.4vw, 4.9rem); }
.article-hero::after { content: "⏱"; position: absolute; right: 4%; top: 30%; font-size: clamp(4rem, 9vw, 8rem); transform: rotate(9deg); opacity: .16; }
.article-hero .article-lede { max-width: 58ch; margin-bottom: 1.6rem; color: #353b42; font-size: clamp(1.1rem, 2vw, 1.3rem); }
.article-byline { display: inline-flex; align-items: center; gap: .75rem; margin: 0; padding: .45rem .9rem .45rem .45rem; background: var(--paper-light); border: var(--line); border-radius: 999px 40px 999px 60px; box-shadow: 3px 3px 0 var(--ink); font-size: .9rem; transform: rotate(-.6deg); }
.article-byline img { width: 44px; height: 44px; border: 2px solid var(--ink); border-radius: 50%; background: var(--blue-soft); }
.article-byline a { font-weight: 750; }

/* ---------- Layout ---------- */
.article-layout { display: grid; grid-template-columns: minmax(0, 220px) minmax(0, 1fr); gap: clamp(2rem, 5vw, 4.5rem); width: min(calc(100% - 2rem), var(--max)); margin: 0 auto clamp(4rem, 8vw, 6rem); align-items: start; }
.article-toc { position: sticky; top: 100px; padding: 1.1rem 1rem 1.2rem; background: var(--paper-light); border: 2px dashed rgba(27,36,48,.45); border-radius: 4px 12px 6px 10px; transform: rotate(-.4deg); font-size: .88rem; }
.article-toc-title { margin-bottom: .6rem; font-family: var(--display); font-weight: 900; letter-spacing: .08em; text-transform: uppercase; font-size: .78rem; }
.article-toc ol { display: grid; gap: .35rem; margin: 0; padding-left: 1.2rem; }
.article-toc li::marker { font-family: var(--display); font-weight: 800; color: var(--coral); }
.article-toc a { text-decoration: none; line-height: 1.35; }
.article-toc a:hover { text-decoration: underline wavy var(--coral); text-underline-offset: 4px; }

/* ---------- Prosa ---------- */
.article-body { min-width: 0; font-size: 1.075rem; line-height: 1.75; }
.article-body > * { max-width: var(--prose); }
.article-body > .gtimes, .article-body > .table-scroll, .article-body > .problem-pair { max-width: none; }
.article-body > * + * { margin-top: 1.15rem; margin-bottom: 0; }
.article-body h2 { margin-top: clamp(3rem, 6vw, 4.5rem); margin-bottom: 1rem; font-family: var(--display); font-size: clamp(1.75rem, 3.3vw, 2.6rem); line-height: 1.1; letter-spacing: -.035em; scroll-margin-top: 100px; }
.article-body h3 { font-family: var(--display); font-size: 1.25rem; line-height: 1.2; margin-bottom: .35rem; }
.article-body p { margin-bottom: 0; }
.article-body strong { background: linear-gradient(transparent 62%, rgba(246,201,77,.55) 62% 92%, transparent 92%); }
.article-body code { padding: .1em .35em; background: var(--paper-light); border: 1px solid rgba(27,36,48,.3); border-radius: 3px; font-size: .9em; }
.article-lead-in { font-size: 1.22rem; }
.article-lead-in::first-letter { float: left; margin: .08em .12em 0 0; font-family: var(--display); font-size: 3.6em; line-height: .8; color: var(--blue); }
.article-body .text-link { font-weight: 650; }

.ink-list, .check-list { display: grid; gap: .55rem; padding-left: 0; list-style: none; }
.ink-list li { position: relative; padding-left: 1.7rem; }
.ink-list li::before { content: ""; position: absolute; left: .1rem; top: .62em; width: 1rem; height: .5rem; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 10'%3E%3Cpath d='M1 6c4-3 9-4 17-1' fill='none' stroke='%23ef765f' stroke-width='2.6' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat center / contain; }
.check-list li { position: relative; padding: .55rem .8rem .55rem 2.6rem; background: var(--paper-light); border: 1.5px solid rgba(27,36,48,.35); border-radius: 3px 8px 4px 9px; }
.check-list li:nth-child(even) { transform: rotate(.25deg); }
.check-list li::before { content: ""; position: absolute; left: .75rem; top: .8rem; width: 1.1rem; height: 1.1rem; border: 2px solid var(--ink); border-radius: 3px 5px 2px 4px; transform: rotate(-4deg); }
.check-list li::after { content: ""; position: absolute; left: .9rem; top: .55rem; width: 1.15rem; height: 1rem; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 18'%3E%3Cpath d='M2 10l5 5L18 2' fill='none' stroke='%233e75d9' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat center / contain; }

/* ---------- Respuesta rápida (post-it) ---------- */
.quick-answer { position: relative; margin-top: 2rem !important; padding: 1.4rem 1.5rem 1.2rem; background: var(--yellow); border: var(--line); box-shadow: var(--shadow); transform: rotate(-.7deg); }
.quick-answer h2 { margin: 0 0 .9rem; font-size: 1.5rem; }
.quick-answer dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; margin: 0; border-top: 1.5px dashed var(--ink); }
.quick-answer dl div { display: flex; justify-content: space-between; gap: 1rem; padding: .5rem .2rem; border-bottom: 1.5px dashed var(--ink); }
.quick-answer dl div:nth-child(odd) { padding-right: 1rem; border-right: 1.5px dashed var(--ink); }
.quick-answer dl div:nth-child(even) { padding-left: 1rem; }
.quick-answer dt { font-size: .95rem; }
.quick-answer dd { margin: 0; font-family: var(--display); font-weight: 900; white-space: nowrap; font-variant-numeric: tabular-nums; }
.quick-answer > p { margin-top: .8rem; font-size: .9rem; }

/* ---------- Fases / pasos ---------- */
.phase-list, .steps-list { display: grid; gap: .9rem; padding: 0; list-style: none; counter-reset: step; }
.phase-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.phase-list li, .steps-list li { position: relative; padding: 1rem 1.1rem 1rem 3.6rem; background: var(--paper-light); border: var(--line); counter-increment: step; }
.phase-list li:nth-child(1) { box-shadow: 4px 4px 0 var(--blue); }
.phase-list li:nth-child(2) { box-shadow: 4px 4px 0 var(--blue); transform: rotate(.4deg); }
.phase-list li:nth-child(3) { box-shadow: 4px 4px 0 #5fb8a2; }
.phase-list li:nth-child(4) { box-shadow: 4px 4px 0 #e2a92a; transform: rotate(-.4deg); }
.phase-list li::before, .steps-list li::before { content: counter(step); position: absolute; left: .9rem; top: .9rem; display: grid; place-items: center; width: 2rem; height: 2rem; font-family: var(--display); font-weight: 900; background: var(--paper); border: 2px solid var(--ink); border-radius: 50% 45% 55% 48%; }
.phase-list p, .steps-list p { font-size: .97rem; color: var(--muted); }
.steps-list li { box-shadow: 4px 4px 0 var(--ink); }
.steps-list li:nth-child(even) { transform: rotate(.3deg); }

/* ---------- Problema A / B ---------- */
.problem-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.2rem; }
.problem-card { padding: 1.2rem 1.25rem; border: var(--line); background: var(--paper-light); }
.problem-card--a { box-shadow: 6px 6px 0 var(--blue); transform: rotate(-.5deg); }
.problem-card--b { box-shadow: 6px 6px 0 var(--coral); transform: rotate(.5deg); }
.problem-card p { font-size: .97rem; }

/* ---------- Capacidad / demanda ---------- */
.concept-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.concept-pair div { padding: .9rem 1rem; border-left: 4px solid var(--blue); background: rgba(188,216,255,.4); }
.concept-pair div + div { border-left-color: var(--coral); background: rgba(239,118,95,.14); }
.concept-pair dt { font-family: var(--display); font-weight: 900; }
.concept-pair dd { margin: 0; }

/* ---------- Caso 178 URLs ---------- */
.crawl-case { margin-inline: 0; padding: 1.2rem 1.3rem; background: var(--paper-light); border: 2px dashed rgba(27,36,48,.5); border-radius: 6px 14px 8px 12px; }
.crawl-case figcaption { font-family: var(--display); font-weight: 800; line-height: 1.3; margin-bottom: 1rem; }
.crawl-case figcaption span { display: block; font-family: var(--body); font-weight: 400; font-size: .85rem; color: var(--muted); }
.crawl-case ul { display: grid; gap: .55rem; margin: 0; padding: 0; list-style: none; }
.crawl-case li { display: grid; grid-template-columns: 8.5rem minmax(0, 1fr); gap: .8rem; align-items: center; font-size: .92rem; }
.crawl-case li b { position: relative; display: block; width: calc(var(--d) / 17 * 100%); min-width: max-content; padding: .1rem .5rem; font-family: var(--display); font-size: .85rem; background: repeating-linear-gradient(-45deg, var(--blue-soft) 0 3px, transparent 3px 7px), var(--paper-light); border: 2px solid var(--ink); border-radius: 3px 6px 2px 5px; white-space: nowrap; }
.crawl-case > p { margin: .9rem 0 0; font-size: .82rem; color: var(--muted); }

/* ---------- Infografía ---------- */
.gtimes { position: relative; margin: clamp(2.5rem, 5vw, 3.5rem) 0 0; padding: clamp(1.2rem, 3vw, 2rem); background: var(--paper-light); border: var(--line); box-shadow: 7px 8px 0 var(--ink); scroll-margin-top: 100px; }
.gtimes .tape { top: -17px; right: 14%; }
.gtimes-head h2 { margin: 0 0 1rem; font-size: clamp(1.6rem, 3vw, 2.3rem); }
.gtimes-head .eyebrow { margin-bottom: .4rem; color: var(--coral); }
.gt-legend { display: flex; flex-wrap: wrap; gap: .5rem 1.4rem; align-items: center; margin: 0 0 1.4rem; padding: .6rem .8rem; list-style: none; font-size: .85rem; border: 1.5px dashed rgba(27,36,48,.4); }
.gt-legend li { display: inline-flex; align-items: center; gap: .5rem; }
.gt-legend-scale { margin-left: auto; color: var(--muted); font-size: .8rem; }
.gt-key { display: inline-block; width: 2.2rem; height: .8rem; border: 2px solid var(--ink); border-radius: 3px 6px 2px 5px; }
.gt-key--typ { background: var(--ink); }
.gt-key--slow { background: repeating-linear-gradient(-45deg, var(--ink) 0 2px, transparent 2px 6px); }
.gt-key-never, .gt-never { font-family: var(--display); font-weight: 900; font-size: 1.3rem; line-height: 1; color: var(--coral); }

.gt-stage { --c: var(--crawl); margin-top: 1.3rem; border: 2px solid var(--ink); border-radius: 4px 10px 6px 12px; overflow: hidden; background: var(--paper-light); }
.gt-stage--index { --c: var(--index); --cdark: #2f8f78; }
.gt-stage--serve { --c: var(--serve); --cdark: #b8860b; }
.gt-stage-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .3rem 1rem; padding: .7rem 1rem; background: var(--c); border-bottom: 2px solid var(--ink); }
.gt-stage--crawl .gt-stage-head { color: var(--paper-light); }
.gt-stage-head h3 { display: inline-flex; align-items: center; gap: .55rem; margin: 0; font-size: 1.45rem; }
.gt-stage-head h3 span { display: grid; place-items: center; width: 1.7rem; height: 1.7rem; font-size: .95rem; color: var(--ink); background: var(--paper-light); border: 2px solid var(--ink); border-radius: 50% 44% 52% 47%; }
.gt-stage-head p { margin: 0; font-size: .88rem; }

.gt-axis, .gt-row { display: grid; grid-template-columns: minmax(0, 15.5rem) minmax(0, 1fr); gap: 1rem; align-items: center; padding-inline: 1rem; }
.gt-axis { padding-block: .55rem .3rem; }
.gt-axis-label { font-family: var(--display); font-size: .7rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.gt-ticks { position: relative; height: 1.1rem; }
.gt-ticks span { position: absolute; transform: translateX(-50%); font-family: var(--display); font-size: .72rem; font-weight: 800; white-space: nowrap; }
.gt-ticks span:first-child { transform: none; }
.gt-ticks .gt-axis-never { color: var(--coral); }
.gt-rows { margin: 0; padding: 0; list-style: none; }
.gt-row { padding-block: .5rem; border-top: 1px dashed rgba(27,36,48,.25); }
.gt-row:hover { background: rgba(246,201,77,.16); }
.gt-label { display: grid; line-height: 1.3; }
.gt-label strong { font-size: .93rem; background: none; }
.gt-label span { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.gt-label b { color: var(--ink); font-weight: 650; }
.gt-track { position: relative; height: 1.5rem; }
.gt-track i { position: absolute; top: -.5rem; bottom: -.5rem; width: 1px; background: rgba(27,36,48,.12); }
.gt-track i.gt-inf { width: 0; background: none; border-left: 1.5px dashed rgba(239,118,95,.6); }
.gt-bar { position: absolute; top: 50%; border: 2px solid var(--ink); }
.gt-bar--slow { height: .85rem; translate: 0 -50%; background: repeating-linear-gradient(-45deg, var(--cdark, var(--c)) 0 2px, transparent 2px 6px); border-style: solid; border-color: rgba(27,36,48,.55); border-radius: 2px 7px 3px 6px; }
.gt-bar--typ { height: 1.05rem; min-width: 1.05rem; translate: 0 -50%; background: var(--c); border-radius: 5px 3px 6px 2px; box-shadow: 2px 2px 0 var(--ink); }
.gt-row:nth-child(3n+1) .gt-bar--typ { rotate: -.8deg; }
.gt-row:nth-child(3n+2) .gt-bar--slow { rotate: .6deg; }
.gt-never { position: absolute; right: 0; top: 50%; translate: 0 -55%; }
.gt-note { margin: 0; padding: .65rem 1rem .8rem; font-size: .85rem; color: var(--muted); border-top: 1.5px dashed rgba(27,36,48,.35); }
.gt-note b { color: var(--ink); }
.gt-source { margin: 1.1rem 0 0; font-size: .8rem; color: var(--muted); }

/* ---------- Tabla ---------- */
.table-scroll { overflow-x: auto; }
.wait-table { width: 100%; min-width: 520px; border-collapse: separate; border-spacing: 0; background: var(--paper-light); border: var(--line); box-shadow: 5px 5px 0 var(--ink); font-size: .95rem; }
.wait-table th, .wait-table td { padding: .65rem .9rem; text-align: left; border-bottom: 1px dashed rgba(27,36,48,.35); }
.wait-table thead th { font-family: var(--display); font-size: .8rem; letter-spacing: .05em; text-transform: uppercase; background: var(--blue-soft); border-bottom: 2px solid var(--ink); }
.wait-table tbody th { font-weight: 650; }
.wait-table td { font-variant-numeric: tabular-nums; white-space: nowrap; }
.wait-table tbody tr:last-child > * { border-bottom: 0; }

/* ---------- FAQ ---------- */
.faq-list { display: grid; gap: .7rem; }
.faq-list details { background: var(--paper-light); border: var(--line); border-radius: 3px 8px 4px 7px; }
.faq-list details[open] { box-shadow: 4px 4px 0 var(--yellow), 4px 4px 0 2px var(--ink); }
.faq-list summary { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .85rem 1rem; cursor: pointer; list-style: none; }
.faq-list summary::-webkit-details-marker { display: none; }
.faq-list summary::after { content: "+"; flex: none; font-family: var(--display); font-size: 1.6rem; font-weight: 900; line-height: 1; transition: transform .2s ease; }
.faq-list details[open] summary::after { transform: rotate(45deg); }
.faq-list summary h3 { margin: 0; font-size: 1.08rem; }
.faq-list details p { padding: 0 1rem 1rem; }

/* ---------- Cita final ---------- */
.closing-quote { margin: clamp(3rem, 6vw, 4rem) 0 0; padding: 1.4rem 1.6rem; color: var(--paper-light); background: var(--ink); border: var(--line); box-shadow: 7px 7px 0 var(--coral); transform: rotate(-.6deg); }
.closing-quote p { margin: 0; font-family: var(--display); font-size: clamp(1.35rem, 2.6vw, 1.85rem); line-height: 1.3; }

/* ---------- Responsive ---------- */
@media (max-width: 1050px) {
  .article-layout { grid-template-columns: minmax(0, 1fr); }
  .article-toc { position: static; transform: none; max-width: var(--prose); }
  .article-toc ol { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 2rem; }
}
@media (max-width: 760px) {
  .article-hero::after { display: none; }
  .quick-answer dl, .phase-list, .problem-pair, .concept-pair { grid-template-columns: minmax(0, 1fr); }
  .quick-answer dl div:nth-child(odd) { padding-right: .2rem; border-right: 0; }
  .quick-answer dl div:nth-child(even) { padding-left: .2rem; }
  .article-toc ol { grid-template-columns: minmax(0, 1fr); }
  .gt-axis, .gt-row { grid-template-columns: minmax(0, 1fr); gap: .35rem; }
  .gt-axis-label { display: none; }
  .gt-ticks span { font-size: .62rem; }
  .gt-legend-scale { margin-left: 0; }
  .crawl-case li { grid-template-columns: minmax(0, 1fr); gap: .2rem; }
}
@media (max-width: 520px) {
  .gtimes { padding: 1rem .75rem; box-shadow: 4px 5px 0 var(--ink); }
  .gt-axis, .gt-row { padding-inline: .65rem; }
  .gt-ticks span:nth-child(2), .gt-ticks span:nth-child(5), .gt-ticks .gt-axis-never { display: none; }
  .article-byline { border-radius: 30px; }
}
@media (prefers-reduced-motion: reduce) {
  .quick-answer, .problem-card, .phase-list li, .steps-list li, .check-list li, .closing-quote, .gt-bar { transform: none !important; rotate: none !important; }
}
