/* Jesús Bravo — "el escritorio de noche".
   A night desk seen from above, lit by a lamp that follows you. Objects are the sections.
   Motion rules (better-motion + emil-design-eng): ease-out for enters, exits shorter, press 0.96–0.98,
   panels enter from 0.98, only transform/opacity/filter animate, loops pause and respect reduced motion. */

:root {
  --ink: #f3efe6;
  --ink-2: #c9c1b4;
  --ink-3: #9a9184;
  --bg: #16130f;
  --wood: #2a201a;
  --paper: #f3efe6;
  --accent: #8d97ff;
  --ease: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-io: cubic-bezier(0.77, 0, 0.175, 1);
  --display: "Funnel Display", system-ui, sans-serif;
  --text: "Funnel Sans", system-ui, sans-serif;
  --hand: "Caveat", cursive;
  --lx: 30vw;
  --ly: 40svh;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; overflow-x: clip; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 400 17px/1.55 var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 16px; top: -60px; z-index: 50; padding: 10px 14px; background: var(--paper); color: var(--bg); border-radius: 8px; text-decoration: none; font-weight: 600; }
.skip:focus { top: 16px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 6px; }

/* ------------------------------------------------------------------ the desk */

.desk {
  position: relative;
  height: 100svh;
  min-height: 640px;
  overflow: hidden;
  isolation: isolate;
}
.desk__wood {
  position: absolute; inset: 0; z-index: 0;
  background-color: var(--wood);
  background-image:
    repeating-linear-gradient(91deg, rgb(255 255 255 / .022) 0 2px, transparent 2px 11px),
    repeating-linear-gradient(89.4deg, rgb(0 0 0 / .10) 0 1px, transparent 1px 37px),
    repeating-linear-gradient(90.6deg, rgb(255 220 180 / .03) 0 3px, transparent 3px 71px),
    linear-gradient(180deg, #2e241c 0%, #251c16 100%);
}
/* the lamp: a warm pool that follows the pointer; everything outside it sinks into the night */
.desk__light {
  position: absolute; inset: 0; z-index: 3; pointer-events: none;
  background:
    radial-gradient(circle at var(--lx) var(--ly), rgb(255 205 140 / .16) 0, rgb(255 190 120 / .07) 22vmax, transparent 40vmax),
    radial-gradient(circle at var(--lx) var(--ly), transparent 0, transparent 16vmax, rgb(8 6 4 / .26) 40vmax, rgb(6 5 3 / .52) 80vmax);
}
.desk__grain {
  position: absolute; inset: -50%; z-index: 4; pointer-events: none; opacity: .13; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ------------------------------------------------------------------ header + intro */

.top { position: fixed; top: 0; right: 0; z-index: 20; padding: 14px clamp(20px, 3vw, 40px); display: flex; align-items: center; gap: 22px; }
.styles { display: flex; gap: 14px; font-size: 13px; letter-spacing: .02em; }
.styles a { color: var(--ink-3); text-decoration: none; padding: 12px 0; transition: color 150ms var(--ease); }
.styles a[aria-current] { color: var(--ink); box-shadow: inset 0 -1px 0 var(--accent); }
@media (hover: hover) and (pointer: fine) { .styles a:hover { color: var(--ink); } }
@media (max-width: 760px) { .top { left: 0; justify-content: space-between; background: linear-gradient(var(--bg), transparent); } }
.lang { display: flex; align-items: center; gap: 6px; font-size: 13px; letter-spacing: .04em; color: var(--ink-3); }
.lang button { background: none; border: 0; cursor: pointer; padding: 10px 4px; color: var(--ink-3); transition: color 150ms var(--ease); }
.lang button[aria-pressed="true"] { color: var(--ink); }
@media (hover: hover) and (pointer: fine) { .lang button:hover { color: var(--ink); } }

.intro {
  position: absolute; z-index: 6;
  left: clamp(20px, 4vw, 64px); top: clamp(28px, 7svh, 72px);
  width: min(30vw, 430px);
}
.intro__name {
  margin: 0 0 14px;
  font: 400 clamp(40px, 4.4vw, 68px)/0.98 var(--display);
  letter-spacing: -0.035em;
}
.dot { color: var(--accent); }
.intro__lead { margin: 0 0 22px; color: var(--ink-2); font-size: clamp(15px, 1.15vw, 17px); max-width: 38ch; }
.intro__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }
.intro__link { font-size: 14px; color: var(--ink-2); text-decoration: none; background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat; transition: background-size 250ms var(--ease), color 150ms var(--ease); padding: 6px 0; }
@media (hover: hover) and (pointer: fine) { .intro__link:hover { background-size: 100% 1px; color: var(--ink); } }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 20px;
  border-radius: 999px;
  background: var(--paper); color: var(--bg);
  font-weight: 600; font-size: 15px; text-decoration: none;
  transition: scale 150ms var(--ease), background-color 200ms var(--ease);
}
.btn:active { scale: .96; }
@media (hover: hover) and (pointer: fine) { .btn:hover { background-color: #fff; } }

/* staged entrance of the intro: title, lead, actions, 100ms apart */
.intro > * { animation: rise 500ms var(--ease) both; }
.intro > :nth-child(2) { animation-delay: 100ms; }
.intro > :nth-child(3) { animation-delay: 200ms; }
@keyframes rise { from { opacity: 0; translate: 0 12px; filter: blur(4px); } to { opacity: 1; translate: 0 0; filter: blur(0); } }

/* ------------------------------------------------------------------ objects */

.objects { list-style: none; margin: 0; padding: 0; }
.obj {
  position: absolute; z-index: 2;
  left: calc(var(--x) * 1%);
  top: calc(var(--y) * 1%);
  width: min(calc(var(--w) * 1vw), calc(var(--w) * 1.6svh));
  rotate: var(--r);
  animation: land 700ms var(--ease) both;
  animation-delay: calc(350ms + var(--i, 0) * 70ms);
}
@keyframes land { from { opacity: 0; translate: 0 -22px; scale: 1.04; } to { opacity: 1; translate: 0 0; scale: 1; } }

.obj__btn {
  all: unset;
  display: block; position: relative; width: 100%;
  cursor: pointer; border-radius: 14px;
  -webkit-tap-highlight-color: transparent;
}
.obj__btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 10px; }
.obj__art {
  display: block; width: 100%; height: auto; overflow: visible;
  filter: drop-shadow(0 12px 14px rgb(0 0 0 / .55)) drop-shadow(0 2px 2px rgb(0 0 0 / .35));
  transition: translate 300ms var(--ease), scale 300ms var(--ease), filter 300ms var(--ease);
}
.obj__label {
  position: absolute; left: 0; bottom: 100%;
  margin-bottom: 12px;
  rotate: calc(-1 * var(--r));
  transform-origin: left bottom;
  display: inline-flex; align-items: baseline; gap: 8px;
  white-space: nowrap;
  font-size: 15px; letter-spacing: .01em; color: rgb(243 239 230 / .78);
  transition: color 200ms var(--ease), translate 300ms var(--ease);
}
.obj__label::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 1px;
  background: currentColor; scale: 0 1; transform-origin: left; transition: scale 300ms var(--ease);
}
.obj__num { font-size: 12px; color: var(--accent); font-variant-numeric: tabular-nums; }

.obj.is-hot .obj__art,
.obj__btn:focus-visible .obj__art {
  translate: 0 -8px; scale: 1.015;
  filter: drop-shadow(0 30px 26px rgb(0 0 0 / .55)) drop-shadow(0 4px 4px rgb(0 0 0 / .3));
}
.obj.is-hot .obj__label, .obj__btn:focus-visible .obj__label { color: var(--ink); translate: 0 -8px; }
.obj.is-hot .obj__label::after, .obj__btn:focus-visible .obj__label::after { scale: 1 1; }
.obj__btn:active .obj__art { scale: .98; transition-duration: 150ms; }

/* ambient loops (paused by the pause button, and under reduced motion) */
.term__l { animation: term 7s linear infinite; }
.term__l2 { animation-delay: .6s; }
.term__l3 { animation-delay: 1.2s; }
@keyframes term { 0%, 6% { opacity: 0; } 10%, 88% { opacity: 1; } 94%, 100% { opacity: 0; } }
.term__cursor { animation: blink 1.1s steps(1, end) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.steam path { animation: steam 3.4s linear infinite; transform-box: fill-box; transform-origin: center bottom; }
.steam__b { animation-delay: -1.7s !important; }
@keyframes steam { 0% { opacity: 0; translate: 0 6px; } 30% { opacity: 1; } 100% { opacity: 0; translate: 0 -16px; } }
.notif { animation: notif 8s var(--ease) infinite; }
.notif--2 { animation-delay: .5s; }
.notif--3 { animation-delay: 1s; }
@keyframes notif { 0%, 4% { opacity: 0; translate: 0 -10px; } 9%, 82% { opacity: 1; translate: 0 0; } 90%, 100% { opacity: 0; translate: 0 0; } }
.led { animation: led 2.4s ease-in-out infinite; }
@keyframes led { 50% { opacity: .35; } }
.is-paused .term__l, .is-paused .term__cursor, .is-paused .steam path, .is-paused .notif, .is-paused .led { animation-play-state: paused; }

.hint {
  position: absolute; z-index: 6; left: 50%; bottom: 20px; translate: -50% 0; margin: 0;
  font-size: 13px; color: var(--ink-3); white-space: nowrap;
  animation: rise 500ms var(--ease) 1.1s both;
}
.pause {
  position: absolute; z-index: 6; left: clamp(20px, 4vw, 64px); bottom: 12px;
  min-height: 44px; padding: 0 2px; background: none; border: 0; cursor: pointer;
  font-size: 13px; color: var(--ink-3); transition: color 150ms var(--ease);
}
@media (hover: hover) and (pointer: fine) { .pause:hover { color: var(--ink); } }

/* ------------------------------------------------------------------ panels */

.panel {
  width: min(1100px, 94vw);
  height: min(700px, 90svh);
  max-width: none; max-height: none;
  padding: 0; border: 0; border-radius: 20px;
  background: #1c1814; color: var(--ink);
  overflow: hidden;
  box-shadow: 0 40px 80px -20px rgb(0 0 0 / .7), 0 0 0 1px rgb(255 255 255 / .06);
  /* exit: shorter and smaller than the enter */
  opacity: 0; translate: 0 -12px; scale: .99;
  transition: opacity 180ms var(--ease), translate 180ms var(--ease), scale 180ms var(--ease), overlay 180ms allow-discrete, display 180ms allow-discrete;
}
.panel[open] {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr);
  opacity: 1; translate: 0 0; scale: 1;
  transition-duration: 420ms;
}
@starting-style { .panel[open] { opacity: 0; translate: 0 12px; scale: .98; } }
.panel::backdrop {
  background: rgb(8 6 4 / 0);
  transition: background-color 300ms var(--ease), overlay 300ms allow-discrete, display 300ms allow-discrete;
}
.panel[open]::backdrop { background: rgb(8 6 4 / .62); }
@starting-style { .panel[open]::backdrop { background: rgb(8 6 4 / 0); } }

.panel__art {
  position: relative; overflow: hidden;
  display: grid; place-items: center; padding: 8%;
  background-color: var(--wood);
  background-image:
    radial-gradient(circle at 50% 46%, rgb(255 205 140 / .22), transparent 62%),
    repeating-linear-gradient(91deg, rgb(255 255 255 / .022) 0 2px, transparent 2px 11px),
    repeating-linear-gradient(89.4deg, rgb(0 0 0 / .10) 0 1px, transparent 1px 37px);
}
.panel__art svg {
  width: 100%; max-height: 100%; height: auto; overflow: visible;
  filter: drop-shadow(0 26px 30px rgb(0 0 0 / .6));
  animation: float 6s ease-in-out infinite;
}
.panel__art[data-art="marketing"] svg { width: 46%; }
.panel__art[data-art="contacto"] svg { width: 80%; }
@keyframes float { 50% { translate: 0 -6px; } }

.panel__body { position: relative; overflow-y: auto; padding: 64px clamp(28px, 4vw, 56px) 96px; }
.panel__kicker { margin: 0 0 18px; font-size: 13px; letter-spacing: .04em; color: var(--ink-3); display: flex; gap: 10px; }
.panel__kicker > :first-child { color: var(--accent); font-variant-numeric: tabular-nums; }
.panel h2 { margin: 0 0 18px; font: 400 clamp(30px, 3vw, 44px)/1.05 var(--display); letter-spacing: -0.03em; text-wrap: balance; }
.panel p { color: var(--ink-2); max-width: 54ch; margin: 0 0 20px; }
.panel strong { color: var(--ink); font-weight: 500; }

.list { list-style: none; margin: 28px 0; padding: 0; border-top: 1px solid rgb(243 239 230 / .12); }
.list li { display: grid; gap: 4px; padding: 16px 0; border-bottom: 1px solid rgb(243 239 230 / .12); }
.list span { color: var(--ink-2); font-size: 16px; }
.chips { font-size: 14px; color: var(--ink-3) !important; }

.work { list-style: none; margin: 28px 0 0; padding: 0; display: grid; gap: 14px; }
.work a {
  display: grid; grid-template-columns: 150px minmax(0, 1fr); grid-template-rows: auto 1fr; gap: 4px 18px;
  padding: 12px; margin: 0 -12px; border-radius: 14px; text-decoration: none;
  transition: background-color 200ms var(--ease);
}
.work img { grid-row: 1 / 3; width: 150px; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 8px; transition: scale 400ms var(--ease); }
.work__t { font-weight: 500; color: var(--ink); display: flex; gap: 10px; align-items: baseline; }
.work__t em { font-style: normal; font-size: 13px; color: var(--accent); }
.work a > span:last-child { color: var(--ink-2); font-size: 15px; }
@media (hover: hover) and (pointer: fine) { .work a:hover { background-color: rgb(243 239 230 / .05); } .work a:hover img { scale: 1.03; } }

.facts { margin: 28px 0 0; border-top: 1px solid rgb(243 239 230 / .12); }
.facts div { display: grid; grid-template-columns: 120px 1fr; padding: 14px 0; border-bottom: 1px solid rgb(243 239 230 / .12); }
.facts dt { color: var(--ink-3); font-size: 14px; }
.facts dd { margin: 0; }

.socials { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 22px; }
.socials a { display: inline-block; padding: 10px 0; color: var(--ink-2); text-decoration: none; transition: color 150ms var(--ease); }
@media (hover: hover) and (pointer: fine) { .socials a:hover { color: var(--ink); } }

.panel__close {
  position: absolute; top: 18px; right: 18px; z-index: 2;
  min-height: 40px; padding: 0 14px; border-radius: 999px;
  border: 1px solid rgb(243 239 230 / .18); background: #1c1814; cursor: pointer;
  font-size: 13px; color: var(--ink-2);
  transition: color 150ms var(--ease), border-color 150ms var(--ease), scale 150ms var(--ease);
}
.panel__close:active { scale: .96; }
.panel__nav {
  position: absolute; right: 0; bottom: 0; z-index: 2;
  width: calc(100% / 2.08 * 1.08); display: flex; justify-content: space-between;
  padding: 16px clamp(28px, 4vw, 56px); background: linear-gradient(transparent, #1c1814 40%);
}
.panel__nav button {
  min-height: 44px; padding: 0 4px; background: none; border: 0; cursor: pointer;
  font-size: 14px; color: var(--ink-3); transition: color 150ms var(--ease);
}
@media (hover: hover) and (pointer: fine) {
  .panel__close:hover { color: var(--ink); border-color: rgb(243 239 230 / .4); }
  .panel__nav button:hover { color: var(--ink); }
}

/* ------------------------------------------------------------------ phone */

@media (max-width: 760px) {
  .desk { height: auto; min-height: 100svh; padding: 84px 20px 96px; overflow: clip; }
  .desk__light { position: fixed; }
  .intro { position: relative; left: auto; top: auto; width: auto; margin-bottom: 64px; }
  .intro__lead { font-size: 16px; }
  .objects { position: relative; z-index: 2; display: grid; grid-template-columns: 1fr 1fr; gap: 72px 18px; align-items: end; }
  .obj { position: relative; left: auto; top: auto; width: auto; }
  .obj[data-panel="ia"], .obj[data-panel="proyectos"], .obj[data-panel="servicios"], .obj[data-panel="sobre"] { grid-column: 1 / -1; }
  .obj[data-panel="ia"] { width: 96%; justify-self: center; }
  .obj[data-panel="marketing"] { width: 48%; justify-self: center; }
  .obj--still { display: none; }
  .obj__label { font-size: 14px; }
  .hint { display: none; }
  .pause { position: relative; left: auto; bottom: auto; margin-top: 48px; }
  .panel { width: 100vw; height: 100svh; border-radius: 0; }
  .panel[open] { grid-template-columns: 1fr; grid-template-rows: 30svh minmax(0, 1fr); }
  .panel__art { padding: 20px; }
  .panel__art svg, .panel__art[data-art] svg { width: auto; height: 100%; max-width: 100%; }
  .panel__body { padding: 32px 22px 110px; }
  .panel__nav { width: 100%; padding: 14px 22px calc(14px + env(safe-area-inset-bottom)); }
  .work a { grid-template-columns: 110px minmax(0, 1fr); }
  .work img { width: 110px; }
}

/* ------------------------------------------------------------------ reduced motion: fewer, gentler */

@media (prefers-reduced-motion: reduce) {
  .intro > *, .obj, .hint { animation: fade 300ms linear both; animation-delay: 0ms; }
  @keyframes fade { from { opacity: 0; } to { opacity: 1; } }
  .term__l, .term__cursor, .steam path, .notif, .led, .panel__art svg { animation-play-state: paused; }
  .obj.is-hot .obj__art, .obj__btn:focus-visible .obj__art { translate: none; scale: none; }
  .obj.is-hot .obj__label, .obj__btn:focus-visible .obj__label { translate: none; }
  .panel, .panel[open] { translate: none; scale: none; }
  @starting-style { .panel[open] { translate: none; scale: none; } }
}
