/* Jordi Babi Montellà — estil: estructura sobria (barra lateral fixa) amb detalls vius.
   Paleta: nit de muntanya + gel + arnica (la flor groga del Pirineu). */
:root {
  --bg: #0f1720;
  --surface: #16212c;
  --line: #243445;
  --text: #e6ebf0;
  --muted: #9aa8b8;
  --ice: #9cc4ff;
  --arnica: #f2b84b;
  --radius: 10px;
  --side: 19rem;
  --display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 1.0625rem/1.65 var(--body); -webkit-font-smoothing: antialiased;
}
a { color: var(--ice); text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { color: var(--arnica); }
:focus-visible { outline: 2px solid var(--arnica); outline-offset: 3px; border-radius: 3px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--arnica); color: #1a1405; padding: .6rem 1rem; z-index: 10; }
.skip:focus { left: 0; }
h1, h2, h3 { font-family: var(--display); line-height: 1.15; margin: 0; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: clamp(2.2rem, 5vw, 3.4rem); margin-bottom: 1rem; }
h2 { font-size: 1.5rem; margin-bottom: .75rem; }
h3 { font-size: 1.15rem; font-weight: 500; }
p { margin: 0 0 1rem; max-width: 62ch; }
.lead { font-size: 1.25rem; color: var(--text); line-height: 1.5; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }

/* ---- estructura ---- */
.shell { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; align-self: start; height: 100vh;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 2.5rem 2rem; border-right: 1px solid var(--line);
}
.brand { display: flex; gap: .85rem; align-items: center; color: var(--text); text-decoration: none; margin-bottom: 2.5rem; }
.mono {
  display: grid; place-items: center; flex: none; width: 2.9rem; height: 2.9rem; border-radius: 50%;
  background: var(--arnica); color: #1a1405; font: 700 1.05rem var(--display);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font: 700 1.1rem var(--display); }
.brand-text span { color: var(--muted); font-size: .85rem; }
.nav { list-style: none; margin: 0; padding: 0; display: grid; gap: .15rem; }
.nav a {
  display: block; padding: .5rem .75rem; margin-left: -.75rem; border-radius: 6px;
  color: var(--muted); text-decoration: none; font-weight: 500; transition: color .15s, background .15s;
}
.nav a:hover { color: var(--text); background: var(--surface); }
.nav a[aria-current="page"] { color: var(--text); background: var(--surface); box-shadow: inset 3px 0 0 var(--arnica); padding-left: 1rem; margin-left: -.75rem; }
.links { list-style: none; margin: 0; padding: 0; display: flex; gap: 1.1rem; font-size: .95rem; }
.content { padding: 4.5rem clamp(1.5rem, 6vw, 5rem) 6rem; max-width: 56rem; outline: none; }
.foot { margin-top: 5rem; padding-top: 1.25rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; }


/* ---- interruptor d'idioma i menú (a dalt a la dreta) ---- */
.topright { position: fixed; top: .85rem; right: .85rem; z-index: 20; display: flex; align-items: center; gap: .5rem; padding: .3rem; border: 1px solid var(--line); border-radius: 999px; background: rgba(15,23,32,.88); backdrop-filter: blur(8px); }
.langsw { position: relative; display: grid; grid-template-columns: 1fr 1fr; width: 5.4rem; height: 2.1rem; border-radius: 999px; background: var(--surface); text-decoration: none; font: 700 .85rem var(--display); letter-spacing: .04em; }
.langsw .l { position: relative; z-index: 1; display: grid; place-items: center; color: var(--muted); transition: color .2s; }
.langsw .thumb { position: absolute; top: 3px; bottom: 3px; left: 3px; width: calc(50% - 3px); border-radius: 999px; background: var(--arnica); transition: transform .22s cubic-bezier(.4,0,.2,1); }
.langsw[data-lang="es"] .thumb { transform: translateX(100%); }
.langsw.flip[data-lang="ca"] .thumb { transform: translateX(100%); }
.langsw.flip[data-lang="es"] .thumb { transform: translateX(0); }
.langsw[data-lang="ca"] .l-ca, .langsw[data-lang="es"] .l-es { color: #1a1405; }
.langsw.flip[data-lang="ca"] .l-ca, .langsw.flip[data-lang="es"] .l-es { color: var(--muted); }
.langsw.flip[data-lang="ca"] .l-es, .langsw.flip[data-lang="es"] .l-ca { color: #1a1405; }
.langsw:hover .l { color: var(--text); }
.menu-btn { display: none; width: 2.1rem; height: 2.1rem; padding: 0; border: 0; border-radius: 50%; background: var(--surface); cursor: pointer; place-items: center; }
.bars, .bars::before, .bars::after { display: block; width: 1.05rem; height: 2px; background: var(--text); border-radius: 2px; transition: transform .2s, opacity .2s; }
.bars { position: relative; }
.bars::before, .bars::after { content: ""; position: absolute; left: 0; }
.bars::before { top: -6px; }
.bars::after { top: 6px; }
.menu-open .bars { background: transparent; }
.menu-open .bars::before { transform: translateY(6px) rotate(45deg); }
.menu-open .bars::after { transform: translateY(-6px) rotate(-45deg); }


/* ---- portada amb cub de Rubik ---- */
.cover { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2rem; align-items: center; }
.hero .lead { max-width: 34ch; }
.cube-box { display: flex; flex-direction: column; align-items: center; gap: .6rem; }
.cube-row { display: flex; align-items: center; justify-content: center; gap: 1.25rem; flex-wrap: wrap; }
.cube-stage { width: 15.5rem; height: 16rem; display: grid; place-items: center; perspective: 900px; user-select: none; -webkit-user-select: none; }
.cube-scene { position: relative; width: 0; height: 0; transform-style: preserve-3d; transform: rotateX(-24deg) rotateY(-36deg); }
.cubie { position: absolute; left: -36px; top: -36px; width: 72px; height: 72px; transform-style: preserve-3d; }
.cubie .f { position: absolute; inset: 0; backface-visibility: hidden; background: #0a0f15; border-radius: 8px; }
.cubie .st { position: absolute; inset: 4px; border-radius: 7px; background: var(--c); cursor: grab; touch-action: none; transition: filter .15s; box-shadow: inset 0 -3px 0 rgba(0,0,0,.12); display: grid; place-items: center; padding: 1px; text-align: center; font: 600 9.5px/1.1 var(--body); color: #0b1118; overflow: hidden; hyphens: auto; user-select: none; -webkit-user-select: none; }
.cubie .st span { display: block; max-width: 100%; overflow-wrap: anywhere; transform: rotate(var(--rot, 0deg)); transition: transform .25s; pointer-events: none; }
.cubie .st:hover { filter: brightness(1.12); }
.cubie .st:active { cursor: grabbing; }
.cube-legend { width: 15rem; height: auto; overflow: visible; }
.cube-legend a { cursor: pointer; }
.cube-legend rect { transition: filter .15s; }
.cube-legend a:hover rect { filter: brightness(1.15); }
.hand { font: 600 17px "Caveat", "Segoe Print", "Bradley Hand", cursive; }
.cube-cap { margin: 0; min-height: 1.4em; text-align: center; font-size: .9rem; color: var(--muted); max-width: 20rem; }
.cube-actions { display: flex; gap: .5rem; }
.cube-actions button, .toggle-all { background: transparent; color: var(--text); border: 1px solid var(--line); border-radius: 999px; padding: .35rem 1rem; font: 500 .9rem var(--body); cursor: pointer; }
.cube-actions button:hover, .toggle-all:hover { border-color: var(--arnica); color: var(--arnica); }
.js .cube-box { min-height: 22rem; }

/* ---- inici ---- */
.hero { padding-bottom: 1rem; }
.role { font: 500 1.35rem var(--display); color: var(--arnica); margin-bottom: 1.25rem; }
.story { display: grid; grid-template-columns: minmax(0, 1fr) 16rem; gap: 2.5rem; align-items: start; margin-top: 3rem; }
.story-text p { max-width: 62ch; }
.photo { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; border-radius: var(--radius); }
.photo.ph { display: grid; place-items: center; background: var(--surface); border: 1px dashed var(--line); color: var(--line); font: 700 4rem var(--display); }
.outside { margin-top: 3rem; }
.outside-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 1rem; }
.outside-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.15rem; }
.outside-item h3 { margin-bottom: .35rem; }
.outside-item p { margin: 0; color: var(--muted); font-size: .97rem; }

/* ---- elements (sempre visibles, sense caixes) ---- */
.items { display: grid; gap: 2rem; margin-top: 1.5rem; }
.item { scroll-margin-top: 1.5rem; }
.item-head { display: flex; flex-direction: column; gap: .1rem; }
.sum-text { display: flex; flex-direction: column; gap: .1rem; }
.sum-text strong { font: 700 1.2rem var(--display); }
.sum-sub { color: var(--muted); font-size: .9rem; }
.item-body { padding-top: .5rem; }
.item-body > p:first-child { margin-top: 0; }
.item-body ul { margin: .5rem 0 0; padding-left: 1.15rem; color: var(--muted); max-width: 62ch; }
.item-body li { margin-bottom: .35rem; }
.related { margin-top: 1rem; padding-top: .75rem; border-top: 1px dashed var(--line); }
.related-title { margin: 0 0 .5rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.rrow { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-bottom: .4rem; }
.rg { color: var(--muted); font-size: .85rem; min-width: 5.5rem; }
.rrow a { display: inline-block; padding: .15rem .7rem; border: 1px solid var(--line); border-radius: 999px; font-size: .88rem; text-decoration: none; color: var(--ice); }
.rrow a:hover { border-color: var(--arnica); color: var(--arnica); }
.pairs.spaced li { padding: .8rem 0 .2rem; border-bottom: 1px solid var(--line); scroll-margin-top: 1.5rem; }

/* ---- botó «tornar» flotant ---- */
.backwrap { margin: 0; }
.backbar { position: fixed; z-index: 25; bottom: 1.1rem; left: calc(var(--side) + 1.5rem); max-width: calc(100vw - 2rem); display: inline-flex; align-items: center; gap: .5rem; padding: .55rem 1.1rem; border: 1px solid #34506b; border-radius: 999px; font-size: .92rem; text-decoration: none; color: var(--text); background: rgba(22,33,44,.96); box-shadow: 0 8px 24px rgba(0,0,0,.5); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.backbar[hidden] { display: none; }
.backbar:hover { border-color: var(--arnica); color: var(--arnica); }

/* ---- trajectòria ---- */
.timeline { list-style: none; margin: 1.5rem 0 0; padding: 0 0 0 1.75rem; border-left: 2px solid var(--line); }
.job { position: relative; padding-bottom: 1rem; }
.job::before { content: ""; position: absolute; left: calc(-1.75rem - 7px); top: 1.2rem; width: 12px; height: 12px; border-radius: 50%; background: var(--bg); border: 2px solid var(--ice); }
.job.current::before { background: var(--arnica); border-color: var(--arnica); box-shadow: 0 0 0 5px rgba(242,184,75,.18); }
.when { color: var(--arnica); font-weight: 500; font-size: .9rem; }
.org { display: block; font: 400 1rem var(--body); color: var(--muted); }
.block { margin-top: 3rem; }
.pairs { list-style: none; padding: 0; margin: 0; display: grid; gap: .75rem; }
.pairs li { display: flex; flex-direction: column; }
.pairs span { color: var(--muted); font-size: .95rem; }
.tag { display: inline-block; padding: .15rem .65rem; border: 1px solid var(--line); border-radius: 999px; font-size: .85rem; color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: .4rem; }
.download { margin-top: 3rem; }
.machine { list-style: none; padding: 0; display: flex; gap: 1.25rem; flex-wrap: wrap; }

/* ---- projectes ---- */
.pillsw { position: relative; display: inline-grid; grid-template-columns: 1fr 1fr; margin-top: 1.5rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); padding: 3px; }
.pillsw .thumb { position: absolute; top: 3px; bottom: 3px; left: 3px; width: calc(50% - 3px); border-radius: 999px; background: var(--arnica); transition: transform .22s cubic-bezier(.4,0,.2,1); }
.pillsw[data-state="leisure"] .thumb { transform: translateX(100%); }
.pillsw button { position: relative; z-index: 1; background: transparent; border: 0; padding: .5rem 1.2rem; font: 600 .92rem var(--display); color: var(--muted); cursor: pointer; border-radius: 999px; white-space: nowrap; }
.pillsw button[aria-checked="true"] { color: #1a1405; }
.pgroup { margin-top: 2rem; }
.pgroup[hidden] { display: none; }
.projects { list-style: none; margin: 1.25rem 0 0; padding: 0; display: grid; gap: 0; border-top: 1px solid var(--line); }
.projects li { padding: 1.4rem 0; border-bottom: 1px solid var(--line); }
.projects h3 a { color: var(--text); text-decoration: none; font: 700 1.3rem var(--display); }
.projects h3 a:hover { color: var(--arnica); }
.projects p { color: var(--muted); margin-top: .4rem; }
.projects .more { margin: 1rem 0 0; }
.projects .more .btn { padding: .4rem 1.1rem; font-size: .92rem; color: var(--arnica); border-color: #6b5420; }
.projects .more .btn:hover { background: var(--arnica); color: #1a1405; }
.crumb { margin-bottom: 1.5rem; font-size: .95rem; }
.visit { margin-top: 2rem; }

/* ---- demo de sincronització ---- */
.sync-demo { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; }
.demo-controls { display: flex; flex-wrap: wrap; gap: .75rem; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg button { background: transparent; color: var(--muted); border: 0; padding: .45rem .95rem; font: inherit; font-size: .9rem; cursor: pointer; }
.seg button[aria-checked="true"] { background: var(--ice); color: #0b1320; font-weight: 500; }
.play { background: var(--arnica); color: #1a1405; border: 0; border-radius: 999px; padding: .5rem 1.25rem; font: 500 .95rem var(--body); cursor: pointer; }
.play:hover { filter: brightness(1.08); }
.pi { display: flex; align-items: center; gap: .6rem; justify-content: center; margin-bottom: 1rem; color: var(--muted); font-size: .9rem; }
.pi-dot { width: .7rem; height: .7rem; border-radius: 50%; background: var(--arnica); box-shadow: 0 0 0 0 rgba(242,184,75,.5); }
.sync-demo.running .pi-dot { animation: ping 1.4s ease-out infinite; }
@keyframes ping { to { box-shadow: 0 0 0 .8rem rgba(242,184,75,0); } }
.phones { display: grid; grid-template-columns: repeat(auto-fit, minmax(5.5rem, 1fr)); gap: .75rem; }
.phone { display: flex; flex-direction: column; align-items: center; gap: .35rem; font-size: .8rem; color: var(--muted); }
.phone-screen { width: 100%; max-width: 5.2rem; aspect-ratio: 9 / 16; border: 2px solid var(--line); border-radius: 12px; background: var(--bg); position: relative; overflow: hidden; }
.bar { position: absolute; left: 0; right: 0; bottom: 0; height: 0%; background: linear-gradient(to top, var(--ice), #6fa0e8); }
.phone-off { font-variant-numeric: tabular-nums; min-height: 1.2em; }
.demo-status { margin: 1rem 0 .25rem; color: var(--text); }

/* ---- contacte ---- */
.contact { list-style: none; margin: 2rem 0 0; padding: 0; display: grid; gap: 1rem; font-size: 1.15rem; }
.contact li { display: grid; grid-template-columns: 7rem 1fr; gap: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.contact span { color: var(--muted); }

.cform { display: grid; gap: 1rem; max-width: 36rem; margin-top: 1rem; }
.cform label { display: grid; gap: .3rem; font-size: .92rem; color: var(--muted); }
.cform input, .cform textarea { width: 100%; padding: .7rem .85rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }
.cform input:focus, .cform textarea:focus { outline: 2px solid var(--arnica); outline-offset: 1px; border-color: transparent; }
.cform textarea { resize: vertical; min-height: 8rem; }
.cform .hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.cform-row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.btn { display: inline-block; padding: .65rem 1.3rem; border: 1px solid var(--line); border-radius: 999px; color: var(--text); text-decoration: none; font: 500 1rem var(--body); background: transparent; cursor: pointer; }
.btn:hover { border-color: var(--arnica); color: var(--arnica); }
.btn.primary { background: var(--arnica); border-color: var(--arnica); color: #1a1405; }
.btn.primary:hover { filter: brightness(1.08); color: #1a1405; }
.btn[disabled] { opacity: .6; cursor: wait; }
.cbox { margin-top: 2rem; }
.foot a { margin-left: .8rem; }

/* ---- mòbil ---- */
.links-in-menu { display: none; }
@media (max-width: 62rem) {
  .shell { display: block; }
  .side { position: static; height: auto; padding: 1.1rem 1.5rem; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { margin-bottom: 0; padding-right: 9.5rem; }
  .topright { position: absolute; }
  .backbar { left: 1rem; }
  .side-bottom { display: none; }
  .menu-btn { display: grid; }
  /* El menú es desplega just sota el botó hamburguesa i es veu per sobre del web */
  .js #site-nav { display: none; position: absolute; z-index: 30; top: 3.9rem; right: .85rem; width: min(19rem, calc(100vw - 1.7rem)); max-height: calc(100vh - 5rem); overflow: auto; padding: .6rem; background: #131e29; border: 1px solid #34506b; border-radius: 14px; box-shadow: 0 18px 40px rgba(0,0,0,.55); }
  .js.menu-open #site-nav { display: block; }
  .js .links-in-menu { display: flex; margin: .5rem .4rem .3rem; padding-top: .7rem; border-top: 1px solid var(--line); }
  .nav a, .nav a[aria-current="page"] { margin-left: 0; padding: .7rem .8rem; box-shadow: none; font-size: 1.1rem; }
  .nav a[aria-current="page"] { background: var(--surface); color: var(--arnica); }
  .content { padding-top: 2rem; }
  .cover { grid-template-columns: 1fr; gap: 1rem; }
  .cube-box { margin-top: .5rem; }
  .story { grid-template-columns: 1fr; }
  .photo { max-width: 14rem; }
  .contact li { grid-template-columns: 1fr; gap: .15rem; }
  .rg { min-width: 100%; }
  .cube-legend { width: 13rem; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .sync-demo.running .pi-dot { animation: none; }
  * { transition: none !important; }
}
