/* creatiu.vallespinosa — full d'estils
   Mobile first · paleta neutra amb l'accent taronja de la Buixots
   Temes: clar, fosc i taronja (data-theme a <html>). Sense triar, segueix el sistema.
   Capes: reset → base → layout → components → utilities */

@layer reset, base, layout, components, utilities;

@font-face { font-family: "Source Serif 4"; font-style: normal; font-weight: 200 900; font-display: swap; src: url("fonts/source-serif-4-latin-opsz-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap; src: url("fonts/inter-latin-wght-normal.woff2") format("woff2"); }
@font-face { font-family: "Buixots"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/buixots.woff2") format("woff2"); }

@view-transition { navigation: auto; }

/* ── Reset ─────────────────────────────────────────────────────────── */
@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; }
  html { -webkit-text-size-adjust: none; text-size-adjust: none; }
  img, picture, svg, video { display: block; max-width: 100%; }
  button, input, select, textarea { font: inherit; color: inherit; }
  ul[role="list"] { list-style: none; padding: 0; }
  h1, h2, h3, p { overflow-wrap: break-word; }
}

/* ── Base ──────────────────────────────────────────────────────────── */
@layer base {
  /* Tema clar (per defecte) */
  :root {
    color-scheme: light;
    --paper: #f4f3ef;
    --paper-2: #eae8e3;
    --surface: #fbfaf7;         /* etiquetes, popup */
    --ink: #1c1c1a;
    --ink-2: #57554f;
    --ink-3: #7f7c75;
    --line: #dcd9d2;
    --accent: #f26f63;          /* el taronja de la Buixots */
    --focus: #c4473d;
    --frame: #f26f63;           /* la vora de les peces en passar-hi per sobre */
    --tone-base: var(--paper);  /* base del color de cada peça */
    --tone-mix: 16%;            /* quant color de la portada hi entra */
    --blend-base: #f1efe9;      /* fons de les imatges amb fons blanc */
    --bubble-bg: #ffffff; --bubble-ink: #1c1c1a;               /* bombolles de text */

    --serif: "Source Serif 4", "Iowan Old Style", Georgia, "Times New Roman", serif;
    --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

    --gutter: clamp(1rem, 0.4rem + 2.6vw, 3rem);
    --maxw: 100rem;
    --inset: 0.8rem;            /* alinea logo, hero i peu amb el text de dins de les peces */
    --edge: max(var(--gutter), (100vw - var(--maxw)) / 2);   /* marge lateral real del contingut */
    --header-h: clamp(3.5rem, 3.3rem + 0.6vw, 4rem);
    --radius: 6px;
    --ease: cubic-bezier(.2, .7, .2, 1);
  }

  /* Tema fosc: triat, o del sistema si no se n'ha triat cap */
  :root[data-theme="dark"] {
    color-scheme: dark;
    --paper: #141413; --paper-2: #1f1e1c; --surface: #24231f;
    --ink: #ecebe6; --ink-2: #aaa79f; --ink-3: #858179; --line: #2f2e2b;
    --focus: #f26f63; --frame: #ffffff; --tone-mix: 22%; --blend-base: #e8e4dc;
    --bubble-bg: #ecebe6; --bubble-ink: #141413;
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
      color-scheme: dark;
      --paper: #141413; --paper-2: #1f1e1c; --surface: #24231f;
      --ink: #ecebe6; --ink-2: #aaa79f; --ink-3: #858179; --line: #2f2e2b;
      --focus: #f26f63; --frame: #ffffff; --tone-mix: 22%; --blend-base: #e8e4dc;
      --bubble-bg: #ecebe6; --bubble-ink: #141413;
    }
  }

  /* Tema taronja: els colors de la Buixots, amb blancs de contrast */
  :root[data-theme="orange"] {
    color-scheme: light;
    --paper: #f26f63; --paper-2: #ee6154; --surface: #ffffff;
    --ink: #11213b; --ink-2: #262a45; --ink-3: #3b3552; --line: #e25a4e;
    --accent: #ffffff; --focus: #11213b; --frame: #000000;
    --tone-base: #ffffff; --tone-mix: 14%; --blend-base: #ffffff;
    --bubble-bg: #ffffff; --bubble-ink: #11213b;
  }

  /* Xinès: lletres xineses de reserva i sense apretar l'espaiat */
  :root:lang(zh) {
    --serif: "Source Serif 4", "Noto Serif SC", "Songti SC", "SimSun", serif;
    --sans: "Inter", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  }
  :lang(zh) h1, :lang(zh) h2, :lang(zh) h3, :lang(zh) .hook { letter-spacing: 0; }

  @media (prefers-contrast: more) {
    :root { --ink-2: var(--ink); --ink-3: var(--ink); }
  }

  html { scrollbar-gutter: stable; hanging-punctuation: first last; scroll-padding-top: calc(var(--header-h) + 1rem); }
  @media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

  body {
    background: var(--paper);
    color: var(--ink);
    font-family: var(--sans);
    font-size: clamp(1rem, 0.96rem + 0.2vw, 1.125rem);
    line-height: 1.55;
    font-optical-sizing: auto;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    transition: background-color .3s var(--ease), color .3s var(--ease);
  }

  h1, h2, h3 {
    font-family: var(--serif);
    font-weight: 460;
    line-height: 1.08;
    letter-spacing: -0.02em;
    text-wrap: balance;
  }
  p { text-wrap: pretty; }

  a { color: inherit; text-decoration-thickness: from-font; text-underline-offset: 0.2em; }
  :focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 3px; }
  ::selection { background: color-mix(in oklab, var(--accent) 40%, transparent); }
}

/* ── Layout ────────────────────────────────────────────────────────── */
@layer layout {
  .wrap { width: min(100% - 2 * var(--gutter), var(--maxw)); margin-inline: auto; }

  /* Capçalera fixa a dalt */
  .site-header {
    position: sticky; top: 0; z-index: 30;
    background: var(--paper);
  }
  .header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: var(--header-h); padding-inline: var(--inset); }
  .header-tools { display: flex; align-items: center; gap: 0.25rem; margin-right: -0.5rem; }

  .hero { padding-block: clamp(1.75rem, 0.75rem + 4vw, 4.5rem) clamp(2rem, 1rem + 4vw, 4.5rem); padding-inline: var(--inset); }

  .works { padding-bottom: clamp(4rem, 2rem + 6vw, 8rem); }
}

/* ── Components ────────────────────────────────────────────────────── */
@layer components {

  /* Salta al contingut */
  .skip {
    position: absolute; left: var(--gutter); top: 0; z-index: 40;
    translate: 0 -120%;
    padding: 0.7em 1.1em; border-radius: var(--radius);
    background: var(--ink); color: var(--paper); font-weight: 600; text-decoration: none;
  }
  .skip:focus-visible { translate: 0 0.75rem; }

  /* Marca: creatiu.vallespinosa amb el punt taronja */
  .logo {
    font-family: var(--serif); font-size: clamp(1.25rem, 1.1rem + 0.55vw, 1.6rem);
    font-weight: 600; letter-spacing: -0.025em; line-height: 1;
    text-decoration: none; white-space: nowrap;
    padding-block: 0.5rem;
  }
  /* El punt és un cercle de debò: la mateixa pupil·la de l'ull */
  .logo .dot, .footer-brand .dot {
    display: inline-block; width: 0.2em; height: 0.2em; margin: 0 0.07em 0 0.09em;
    border-radius: 50%; background: var(--accent);
    color: transparent; overflow: hidden; vertical-align: 0.01em; line-height: 0;
  }
  :root.eye-talking .logo .dot { animation: talk .45s ease-in-out infinite alternate; }
  .logo .host { color: var(--ink-3); font-weight: 420; }

  /* Botons d'icona */
  .icon-btn {
    display: inline-grid; place-items: center; width: 2.75rem; height: 2.75rem;
    border: 0; border-radius: 50%; background: transparent; color: var(--ink-2);
    cursor: pointer; transition: background-color .2s, color .2s;
  }
  .icon-btn:hover { background: color-mix(in oklab, var(--ink) 9%, transparent); color: var(--ink); }
  .icon-btn svg { width: 1.25rem; height: 1.25rem; }
  .icon-btn[hidden] { display: none; }

  /* L'ull: obre els ajustos, et mira i et parla */
  .mark-btn { color: var(--ink); }
  .mark-btn .mark { width: 1.6rem; height: 1.6rem; overflow: visible; }
  .mark .pupil { transform-box: fill-box; transform-origin: center; transition: scale .25s var(--ease), opacity .2s; }
  .mark-btn.is-open .pupil { scale: 1.12; }
  .mark-btn.is-talking .pupil { animation: talk .45s ease-in-out infinite alternate; }
  @keyframes talk { to { scale: 1.3; } }
  .mark-btn.is-blinking .pupil { scale: 1 0.12; transition-duration: .07s; }
  /* Tanca els ulls a poc a poc i els torna a obrir sense pressa */
  .mark-btn.is-drowsy .pupil { scale: 1 0.1; transition-duration: .5s; }
  .mark-btn.is-opening .pupil { transition-duration: .45s; }
  .mark-btn.is-sleeping .pupil { scale: 0.75; opacity: 0.75; }
  .mark-btn.is-noticing .pupil { scale: 1.15; }
  /* Content: la pupil·la s'obre molt (ja no es tanca en corba) */
  .mark-btn.is-happy .pupil { scale: 1.12; }
  .mark-btn.is-buzzing .mark { animation: buzz .07s linear 10; }
  @keyframes buzz {
    25% { translate: -0.6px 0.3px; rotate: -4deg; }
    75% { translate: 0.6px -0.3px; rotate: 4deg; }
  }

  /* Portada */
  .eyebrow {
    min-height: 1.2em;
    font-size: 0.75rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase;
    color: var(--ink-2);
  }
  .hero h1 {
    margin-top: 0.6em;
    max-width: 20ch;
    font-size: clamp(2rem, 1.4rem + 2.5vw, 4rem);
    line-height: 1.04;
    letter-spacing: -0.03em;
    font-weight: 450;
  }
  :root[data-theme="orange"] .hero h1 { color: #ffffff; }
  /* El subtítol mai és més ample que el titular: salta de línia on salta el titular, en tots els idiomes */
  .hero-title { width: fit-content; max-width: 100%; }
  .hook {
    width: 0; min-width: 100%;
    text-wrap: balance;
    margin-top: 0.35em;
    font-family: var(--serif);
    font-size: clamp(1.3rem, 1.05rem + 1vw, 2.125rem);
    line-height: 1.15;
    letter-spacing: -0.02em;
    color: var(--ink-3);
  }

  /* ── El mur ────────────────────────────────────────────────────── */
  /* Graella de cel·les quadrades: 2, 4, 6 o 8 columnes segons l'espai.
     Cada peça ocupa entre 2×1 i 3×2 cel·les, i la mida canvia a cada visita. */
  .wall { container: wall / inline-size; }
  .wall ul {
    --cols: 2;
    --gap: clamp(0.5rem, 0.3rem + 0.8vw, 1rem);
    --col: calc((100cqi - (var(--cols) - 1) * var(--gap)) / var(--cols));
    display: grid; gap: var(--gap);
    grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
    grid-auto-rows: var(--col);
    grid-auto-flow: dense;
  }
  @container wall (min-width: 40rem) { .wall ul { --cols: 4; } }
  @container wall (min-width: 64rem) { .wall ul { --cols: 6; } }
  @container wall (min-width: 92rem) { .wall ul { --cols: 8; } }

  .size-b { grid-column: span 2; }
  .size-c { grid-row: span 2; }
  .size-d, .size-e, .size-f { grid-column: span 2; grid-row: span 2; }
  @container wall (min-width: 40rem) {
    .size-e { grid-column: span 3; }
    .size-f { grid-row: span 3; }
  }

  /* El fons de cada peça surt del color de la seva portada */
  .work {
    display: flex; min-width: 0;
    --tone: color-mix(in oklab, var(--dom, var(--ink-3)) var(--tone-mix), var(--tone-base));
  }

  /* Cada peça: la imatge i, a sota, una franja compacta amb la categoria i el títol */
  .card {
    position: relative; flex: 1; min-width: 0;
    display: flex; flex-direction: column;
    background: var(--tone);
    border-radius: var(--radius);
    overflow: hidden;
    color: var(--ink); text-decoration: none;
  }
  .card-media { position: relative; flex: 1 1 0; min-height: 0; overflow: hidden; background: var(--media-bg, var(--tone)); container-type: size; }
  .blend .card-media { background: var(--media-bg, color-mix(in oklab, var(--dom, #fff) 10%, var(--blend-base))); }
  .card-media picture, .card-media img { width: 100%; height: 100%; }
  .card-media img { object-fit: cover; object-position: var(--focus, 50% 50%); }
  .fit-contain .card-media img { object-fit: contain; padding: 9cqmin; }   /* marge relatiu a la mida de la imatge, no a l'amplada */
  .blend .card-media img { mix-blend-mode: multiply; }
  .pixel .card-media img { image-rendering: pixelated; }

  .card-cap { display: grid; gap: 0.1rem; padding: 0.55rem 0.8rem 0.65rem; }
  .card-kind {
    font-size: 0.5rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
    color: color-mix(in oklab, currentColor 62%, transparent);
  }
  /* Al mòbil, l'etiqueta una mica més gran perquè es llegeixi */
  @media (max-width: 39.99rem) { .card-kind { font-size: 0.62rem; } }
  .card-title {
    font-size: clamp(1.1rem, 1rem + 0.3vw, 1.3rem); line-height: 1.15;
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
  }
  .card-desc {
    margin-top: 0.15rem;
    font-size: 0.78rem; line-height: 1.4;
    color: color-mix(in oklab, currentColor 72%, transparent);
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
  }
  .size-c .card-desc { -webkit-line-clamp: 3; line-clamp: 3; }
  .size-d .card-cap, .size-e .card-cap, .size-f .card-cap { padding: 0.7rem 1rem 0.8rem; }

  /* Apaïsades (2×1): el text al costat de la imatge, dins del mateix bloc */
  .size-b .card { flex-direction: row; }
  .size-b .card-media { flex: 1.35 1 0; }
  .size-b .card-cap { flex: 1 1 0; align-content: end; min-width: 0; }
  .size-b .card-desc { -webkit-line-clamp: 4; line-clamp: 4; }
  .size-d .card-title, .size-e .card-title, .size-f .card-title { font-size: clamp(1.2rem, 1rem + 0.65vw, 1.6rem); }

  /* Una vora fina de color en passar-hi per sobre (sense ombres ni zoom) */
  .card::after {
    content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
    border: 1px solid transparent;
    transition: border-color .2s var(--ease);
  }
  @media (hover: hover) { .card:hover::after { border-color: color-mix(in oklab, var(--frame) 45%, transparent); } }
  .card:focus-visible { outline-offset: 4px; }
  .card:focus-visible::after, .work.is-speaking .card::after { border-color: color-mix(in oklab, var(--frame) 45%, transparent); }

  /* Mostrari viu de la Buixots: fons blau fosc, el nom en taronja i la frase en blanc */
  .specimen {
    position: absolute; inset: 0;
    display: grid; place-content: center start; text-align: left; gap: 0.12em;
    font-family: "Buixots", var(--sans);
    padding: 9cqi;
    background: #22353b;
  }
  .specimen-big { font-size: min(16cqi, 24cqh); line-height: 0.95; color: #f26f63; }
  .specimen-set { font-size: min(9cqi, 13cqh); line-height: 1.05; color: #ebebeb; white-space: pre-line; }
  .work:has(.specimen) { --tone: color-mix(in oklab, var(--dom) 12%, var(--tone-base)); }

  /* Cartell animat de Finestres enceses: una sola finestra sobre fons blau que va canviant, una darrere l'altra,
     amb un fade. Cicle de 70 s: cada finestra entra durant 4,5 s, es queda 2,5 s i se'n va durant 4,5 s mentre entra la següent. */
  .fw { position: absolute; inset: 0; display: block; background: radial-gradient(120% 100% at 50% 35%, #17274f, #08102a); }
  .fw-i { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; opacity: 0; animation: fw-fade 70s ease-in-out infinite; animation-delay: calc(var(--i) * 7s); }
  .fw-i svg { width: auto; overflow: visible; }
  @keyframes fw-fade { 0% { opacity: 0; } 6.43% { opacity: 1; } 10% { opacity: 1; } 16.43% { opacity: 0; } 100% { opacity: 0; } }
  @media (prefers-reduced-motion: reduce) { .fw-i { animation: none; } .fw-i:first-child { opacity: 1; } }

  /* Entrada suau en fer scroll */
  @media (prefers-reduced-motion: no-preference) {
    @supports (animation-timeline: view()) {
      .work { animation: rise linear both; animation-timeline: view(); animation-range: entry 0% entry 30%; }
      @keyframes rise { from { opacity: 0; translate: 0 1.25rem; } }
    }
  }

  /* ── Bombolles: l'ull (a dalt) i les peces (al costat del cursor) ── */
  .voice, .tip {
    position: fixed; z-index: 35;
    max-width: min(18rem, 100vw - 2 * var(--gutter));
    padding: 0.55rem 0.75rem 0.6rem;
    border: 1px solid var(--bubble-ink);
    background: var(--bubble-bg); color: var(--bubble-ink);
    font: 0.8125rem/1.45 var(--mono);
    pointer-events: none;
    transition: opacity .2s var(--ease), scale .2s var(--ease);
    @starting-style { opacity: 0; scale: 0.96; }
  }
  .voice[hidden], .tip[hidden] { display: none; }
  .voice {
    top: calc(var(--header-h) + 0.35rem);
    right: calc(var(--edge) + var(--inset) - 0.5rem);
    transform-origin: top right;
  }
  .voice::before {               /* el pic que apunta a l'ull */
    content: ""; position: absolute; top: -0.4rem; right: 1.025rem;
    width: 0.7rem; height: 0.7rem; rotate: 45deg;
    background: var(--bubble-bg); border-left: 1px solid var(--bubble-ink); border-top: 1px solid var(--bubble-ink);
  }
  .voice.at-cursor, .tip { top: 0; left: 0; right: auto; transform-origin: top left; }
  .voice.at-cursor::before { display: none; }
  .tip-kind {
    display: block; margin-bottom: 0.2rem;
    font: 600 0.6875rem/1.3 var(--sans); letter-spacing: 0.1em; text-transform: uppercase;
    opacity: 0.7;
  }
  .voice-text::after, .tip-text::after { content: "▍"; animation: caret .8s steps(1) infinite; margin-left: 1px; }
  .voice.is-done .voice-text::after, .tip.is-done .tip-text::after { content: none; }
  @keyframes caret { 50% { opacity: 0; } }

  /* Tornar a dalt: botó flotant a baix a la dreta, alineat amb l'ull */
  .to-top {
    position: fixed; z-index: 25;
    right: calc(var(--edge) + var(--inset) - 0.5rem);
    bottom: max(1rem, env(safe-area-inset-bottom));
    display: grid; place-items: center; width: 2.75rem; height: 2.75rem;
    border: 0; border-radius: 50%;
    background: transparent; color: var(--ink);
    cursor: pointer;
    transition: opacity .25s var(--ease), translate .25s var(--ease), background-color .2s;
    @starting-style { opacity: 0; translate: 0 0.75rem; }
  }
  .to-top[hidden] { display: none; }
  .to-top:hover { background: color-mix(in oklab, var(--ink) 9%, transparent); }
  .to-top svg { width: 1.6rem; height: 1.6rem; stroke-width: 2.2; }   /* el mateix gruix que l'anell de l'ull */

  /* ── Ajustos: popup centrat que surt de l'ull ──────────────────── */
  .settings {
    position: fixed; inset: 36svh 0 auto; transform: translateY(-50%);
    width: min(100vw - 2 * var(--gutter), 23rem); height: fit-content;
    margin: 0 auto; padding: clamp(1.75rem, 1.3rem + 1.6vw, 2.5rem);
    display: grid; gap: 1.1rem;
    border: 1px solid var(--line); border-radius: 18px;
    background: var(--surface); color: var(--ink);
    opacity: 0; translate: 0 -0.5rem; scale: 0.98; transform-origin: center;
    transition: opacity .5s var(--ease), translate .5s var(--ease), scale .5s var(--ease), overlay .5s allow-discrete, display .5s allow-discrete;   /* en sortir-ne, s'esvaeix a poc a poc */
  }
  .settings:popover-open { opacity: 1; translate: 0 0; scale: 1; }
  .settings.is-closing { opacity: 0; translate: 0 -0.5rem; scale: 0.98; }   /* tancament amb fade (el fa servir el JS en sortir-ne amb el ratolí) */
  .settings.is-closing:popover-open::backdrop { background: rgb(20 20 19 / 0); }   /* el fons s'esvaeix alhora que el popup */
  @starting-style { .settings:popover-open { opacity: 0; translate: 0 -0.5rem; scale: 0.98; } }
  .settings:not(:popover-open) { display: none; }
  .settings:popover-open { display: grid; }
  .settings::backdrop {
    background: rgb(20 20 19 / 0);
    transition: background-color .5s var(--ease), overlay .5s allow-discrete, display .5s allow-discrete;
  }
  .settings:popover-open::backdrop { background: rgb(20 20 19 / .3); }
  @starting-style { .settings:popover-open::backdrop { background: rgb(20 20 19 / 0); } }

  .segmented { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 3px; padding: 3px; border-radius: 11px; background: var(--paper-2); }
  .segmented label, .segmented a, .segmented span {
    position: relative;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.3rem;
    min-height: 2.5rem; padding: 0.45rem 0.25rem; border-radius: 8px; line-height: 1;
    font-size: 0.875rem; font-weight: 600; color: var(--ink-2); text-decoration: none;
    cursor: pointer; transition: background-color .15s, color .15s;
  }
  .segmented label:hover, .segmented a:hover { color: var(--ink); }
  .segmented svg { width: 1.35rem; height: 1.35rem; }
  .segmented input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
  .segmented label:has(input:checked), .segmented a[aria-current="page"] { background: var(--surface); color: var(--ink); outline: 1px solid var(--line); }
  .segmented label:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 1px; }
  .langs a, .langs span { letter-spacing: 0.08em; }
  .langs span { color: var(--ink-3); opacity: 0.55; cursor: default; }
  :root[data-theme="orange"] .segmented { background: #fde4df; }

  .switch-row {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    min-height: 2.5rem; padding: 0 0.15rem 0 0.35rem;
    font-size: 0.9375rem; font-weight: 550; color: var(--ink-2); cursor: pointer;
  }
  .switch-row input {
    appearance: none; flex: none; margin: 0; cursor: pointer;
    width: 2.75rem; height: 1.6rem; border-radius: 999px;
    background: var(--line) radial-gradient(circle, var(--surface) 0 0.55rem, transparent 0.6rem) no-repeat left 0.125rem center / 1.35rem 1.35rem;
    transition: background-color .2s, background-position .2s var(--ease);
  }
  .switch-row input:checked { background-color: var(--ink); background-position: right 0.125rem center; }
  :root[data-theme="orange"] .switch-row input:checked { background-color: #f26f63; }

  /* ── Hero: titulars que s'escriuen i quatre peces animades ─────── */
  .hx-head { max-width: 62rem; }
  .hero .hx-title { display: grid; max-width: 26ch; }
  .hx-title > span { grid-area: 1 / 1; }
  .hx-ghost { visibility: hidden; }
  .hx-caret { display: inline-block; width: 0.4em; height: 0.8em; margin-left: 0.06em; vertical-align: -0.04em; background: var(--accent); animation: caret 1s steps(1) infinite; }
  .hx-title.is-typing .hx-caret { animation: none; }
  :root[data-theme="orange"] .hx-caret { background: #ffffff; }
  .hx-cells { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(1rem, 0.5rem + 1.6vw, 2rem); margin: clamp(2.2rem, 1.5rem + 3vw, 4rem) 0 0; padding: 0; list-style: none; }
  .hx-fx { position: relative; aspect-ratio: 4 / 3; border-radius: var(--radius); overflow: hidden; background: var(--paper-2); }
  .hx-fx canvas { cursor: default !important; }
  [data-inv].is-inv canvas { filter: invert(1); }
  /* Un píxel del taronja de la casa a cada peça; el de la peça que es mou es passeja */
  .hx-dot { position: absolute; z-index: 1; width: 6px; height: 6px; background: var(--accent); left: var(--dx, 70%); top: var(--dy, 22%); transition: left 1.6s var(--ease), top 1.6s var(--ease); }
  .hx-name { margin: 0.9rem 0 0; font-family: var(--serif); font-weight: 400; font-size: clamp(1.05rem, 0.95rem + 0.4vw, 1.35rem); line-height: 1.2; letter-spacing: -0.01em; text-wrap: balance; }
  .hx-sub { margin: 0.35rem 0 0; font-size: 0.85rem; line-height: 1.5; color: var(--ink-2); text-wrap: pretty; }
  /* El separador abans de les feines: ratlles verticals curtes de gruixos i separacions a l'atzar */
  .hx-sep { position: relative; margin: clamp(3.5rem, 2.5rem + 4vw, 6.5rem) 0 clamp(1rem, 0.5rem + 1.5vw, 2rem); cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='9' height='9'%3E%3Cpath d='M4.5 0v9M0 4.5h9' stroke='%23161616' stroke-width='1'/%3E%3C/svg%3E") 4 4, crosshair; }
  .hx-sep::before { content: ""; position: absolute; inset: -12px 0; }
  .hx-sep canvas, .ln canvas { position: absolute; top: 0; image-rendering: pixelated; pointer-events: none; }
  .hx-sep canvas { left: 0; }
  @media (max-width: 47.99rem) { .hx-cells { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 1.8rem; } }
  @media (prefers-reduced-motion: reduce) { .hx-caret { animation: none; } .hx-dot { transition: none; } }

  /* ── Marges: textos verticals i, a l'esquerra, línies de píxels ── */
  .mg { display: none; }
  @media (min-width: 64rem) and (hover: hover) {
    .mg { display: block; position: fixed; z-index: 3; bottom: 1.4rem; width: 26px; }
    .mg-l { left: 0.9rem; }
    .mg-r { right: 1.9rem; }
    .mg-tag { display: block; writing-mode: vertical-rl; font: 500 0.62rem/1 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); white-space: nowrap; transition: opacity .3s; }
    .mg-l .mg-tag { rotate: 180deg; }
    .mg-r .mg-tag { margin-left: auto; }
    .ln { position: relative; width: 0.62rem; margin: 0 0 1.6rem; cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='9' height='9'%3E%3Cpath d='M4.5 0v9M0 4.5h9' stroke='%23161616' stroke-width='1'/%3E%3C/svg%3E") 4 4, crosshair; }
    .ln::before { content: ""; position: absolute; inset: -10px -16px; }
    .ln canvas { left: 50%; translate: -50% 0; }
  }

  /* ── Peu: crida, graella d'informació i rètol en dither, sense franges ── */
  .site-footer { margin-top: clamp(4rem, 3rem + 5vw, 8rem); }
  .foot-in { margin-inline: var(--inset); }
  .foot-label { margin: 0 0 1rem; font-family: var(--sans); font-size: 0.68rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); }
  .foot-cta { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem 3rem; padding-block: clamp(2rem, 1.5rem + 2vw, 3.2rem); }
  .foot-ask { margin: 0; max-width: 18em; font-family: var(--serif); font-size: clamp(1.8rem, 1.1rem + 2.8vw, 3.6rem); line-height: 1.08; letter-spacing: -0.025em; text-wrap: balance; }
  .foot-mail { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.4rem 0.9rem; margin: 0; }
  .foot-mail a { font-family: var(--serif); font-size: clamp(1.35rem, 1.1rem + 1vw, 1.9rem); letter-spacing: -0.01em; color: var(--ink); text-decoration-color: var(--accent); text-underline-offset: 0.2em; }
  .foot-mail .pending { font-size: 0.95rem; color: var(--ink-3); }
  .foot-copy { padding: 0.3rem 0.75rem; border: 1px solid var(--line); border-radius: 999px; background: none; cursor: pointer;
    font: 600 0.72rem/1 var(--sans); letter-spacing: 0.04em; color: var(--ink-2); transition: border-color .2s, color .2s; }
  .foot-copy:hover { border-color: var(--accent); color: var(--ink); }
  .foot-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, 2.2fr) minmax(0, 1fr); gap: 2rem clamp(1.5rem, 1rem + 2vw, 3rem); padding-block: 1.6rem clamp(2.5rem, 2rem + 2vw, 3.5rem); font-size: 0.9rem; line-height: 1.55; color: var(--ink-2); }
  .foot-grid p, .foot-grid ul { margin: 0; padding: 0; list-style: none; }
  .foot-grid a { color: var(--ink); text-decoration-color: var(--line); text-underline-offset: 0.2em; }
  .foot-grid a:hover { text-decoration-color: var(--accent); }
  .foot-index ul { columns: 2; column-gap: 2rem; }
  .foot-index li { display: flex; justify-content: space-between; gap: 0.8rem; break-inside: avoid; }
  .foot-index li span { flex: none; font-size: 0.72rem; color: var(--ink-3); }
  /* El correu i el WhatsApp en dither: un bloc que s'aclareix quan hi passes el ratolí */
  .foot-mail { flex-direction: column; align-items: flex-start; gap: 0.45rem; }
  .dz-hint { margin: 0 0 0.2rem; font: 500 0.62rem/1 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); }
  .dz-row { display: flex; align-items: center; gap: 0.6rem; }
  .dz-ico { flex: none; width: 1.05rem; height: 1.05rem; fill: none; stroke: var(--ink-3); stroke-width: 1.4; stroke-linejoin: round; }
  .dz { display: inline-block; padding: 0; border: 0; background: none; cursor: crosshair; font-family: var(--sans); font-size: 1rem; color: var(--ink); line-height: 1.3; }
  .dz canvas { display: block; image-rendering: pixelated; }
  .dz-done { display: inline-flex; align-items: center; font-family: var(--sans); font-size: 1rem; line-height: 1.3; white-space: nowrap; }
  /* El lloc del botó «Copia» hi és des del principi (invisible): en rascar no es mou res */
  .dz-slot { visibility: hidden; }
  .foot-mail .dz-done a { font: inherit; letter-spacing: 0; color: var(--ink); text-decoration-color: var(--accent); text-underline-offset: 0.2em; }
  .dz-pending { color: var(--ink-3); }
  /* Sota la crida: una línia amb tres creus de tall i un parell de creus petites, a l'atzar */
  .foot-rule { position: relative; height: 44px; }
  .foot-rule svg, .foot-rule canvas { position: absolute; top: 0; left: 0; overflow: visible; }
  .foot-rule canvas { image-rendering: pixelated; }
  @media (max-width: 63.99rem) { .foot-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .foot-index { grid-column: 1 / -1; } }
  @media (max-width: 39.99rem) { .foot-grid { grid-template-columns: minmax(0, 1fr); } .foot-index ul { columns: 1; } }

  /* La signatura: «Fet amb tecnologia i imaginació» (la mateixa a les mini webs) */
  /* Tota la frase en lletra de màquina i del mateix color; el cursor taronja, al final */
  .sig {
    padding: 0 var(--gutter) clamp(2.5rem, 2rem + 2vw, 3.5rem);
    text-align: center; text-wrap: balance;
    font-family: var(--mono); font-size: 0.9rem; letter-spacing: 0.02em;
    color: var(--ink);
  }
  /* El cursor és un bloc dibuixat (no un caràcter), perquè surti igual de gruixut amb qualsevol lletra */
  .sig::after {
    content: ""; display: inline-block; width: 0.45em; height: 1.05em; margin-left: 0.12em;
    vertical-align: -0.17em; background: var(--accent);
    animation: caret 1s steps(1) infinite;
  }
  :root[data-theme="orange"] .sig::after { background: #ffffff; }


  /* Pàgina d'error */
  .notfound { padding-block: clamp(3rem, 1rem + 8vw, 8rem); }
  .notfound h1 { font-size: clamp(2rem, 1.4rem + 2.5vw, 3.5rem); letter-spacing: -0.03em; }
  .notfound p { margin-top: 0.6em; font-size: clamp(1.05rem, 1rem + 0.4vw, 1.25rem); color: var(--ink-2); }
  .notfound a { display: inline-block; margin-top: 1em; font-weight: 600; text-decoration-color: var(--accent); }
}

/* ── Utilities ─────────────────────────────────────────────────────── */
@layer utilities {
  .vh {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
  }
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
    @view-transition { navigation: none; }
  }
}
