/* ============================================================
   bermudi.dev — cube.css
   Scroll-driven 3D portfolio cube. Light warm commercial theme.
   Mechanics adapted from Luis Martinez Riancho's "Six Faces"
   technique (scroll-driven rotateX/rotateY interpolation with
   inertia smoothing). Repointed at commerce: faces = projects.
   ============================================================ */

@import url("https://fonts.googleapis.com/css2?family=Bebas+Neue&family=Inter:wght@400;500;600&family=DM+Mono:wght@400;500&display=swap");

:root {
  --bg: #f5f1e8;
  --bg-2: #efe9dc;
  --cube-face: #e2d6c2;
  --ink: #1a1410;
  --ink-dim: #5a4f44;
  --ink-muted: #948779;
  --accent: #b8421f;
  --accent-dark: #963318;
  --accent-soft: rgba(184, 66, 31, 0.08);
  --green: #3a7d2c;
  --hairline: 1px;
  --ui-inset: 2rem;
  --card-bg: rgba(255, 252, 246, 0.82);
  --card-border: rgba(184, 66, 31, 0.18);
  --font-display: "Bebas Neue", sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --font-mono: "DM Mono", monospace;
  --z-ui: 10;
  --reveal-offset: 0.625rem;
  --reveal-duration: 0.5s;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: auto; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  overflow-x: clip;   /* clip, not hidden: hidden forces overflow-y:auto and breaks position:sticky */
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }

/* ============================================================
   HEADER (sticky, minimal)
   ============================================================ */
.site-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  background: rgba(245, 241, 232, 0.88);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(184, 66, 31, 0.1);
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.header-inner { max-width: 1200px; margin: 0 auto; padding: 0.9rem 1.5rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { text-decoration: none; font-family: var(--font-display); font-size: 1.4rem; letter-spacing: 0.03em; color: var(--ink); }
.brand em { font-style: normal; color: var(--accent); }
.site-nav { display: flex; align-items: center; gap: 1.6rem; font-family: var(--font-mono); font-size: 0.8rem; }
.site-nav a { text-decoration: none; color: var(--ink-dim); transition: color 0.2s ease; }
.site-nav a:hover { color: var(--accent); }
.site-nav .nav-cta { color: var(--bg); background: var(--accent); padding: 0.55rem 1.1rem; font-weight: 500; }

/* ============================================================
   3D CUBE SCENE — the signature element
   ============================================================ */
#scene {
  position: fixed; inset: 0; z-index: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  transition: opacity 0.5s ease;
}
#scene.fade { opacity: 0; pointer-events: none; }

#cube {
  --s: min(70vw, 60vh, 480px);
  --perspective: 1100px;
  width: var(--s); height: var(--s);
  position: relative;
  transform-style: preserve-3d;
  /* Keep perspective on the cube itself. Firefox Android can distort a
     perspective context inherited through the sticky mobile scene. */
  transform: perspective(var(--perspective)) rotateX(90deg) rotateY(0deg);
  will-change: transform;
}

.face {
  position: absolute; inset: 0; overflow: hidden;
  backface-visibility: hidden;
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
  border: 1px solid rgba(184, 66, 31, 0.22);
}

/* F0 IMPULSO — full terracotta brand poster */
.face-brand { background: var(--accent); }
.face-massive {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 6.5vw, 4.2rem);
  line-height: 0.9; letter-spacing: 0.02em;
  color: var(--bg); text-align: center;
}

/* F1 SERVICIOS / F4 PRUÉBALO — icon grids on cream */
.face-services, .face-try { background: var(--cube-face); }
.face-icons {
  display: flex; gap: 1.4rem; align-items: center; justify-content: center;
}
.face-icon {
  display: flex; flex-direction: column; align-items: center; gap: 0.45rem;
  color: var(--accent);
}
.face-icon i { font-size: clamp(1.7rem, 4vw, 2.6rem); }
.face-icon span {
  font-family: var(--font-mono); font-size: 0.58rem; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--ink-dim);
}
.face-arrow { font-size: 1.3rem; color: var(--accent); margin-top: 0.5rem; }

/* F2 POR QUÉ YO — dark ink with giant numeral */
.face-why { background: var(--ink); flex-direction: column; gap: 0.4rem; }
.face-glyph {
  font-family: var(--font-display);
  font-size: clamp(4.5rem, 13vw, 8rem);
  line-height: 0.85; color: var(--accent);
}
.face-glyph-label {
  font-family: var(--font-mono); font-size: 0.6rem; letter-spacing: 0.16em;
  text-transform: uppercase; color: rgba(245,241,232,0.55);
  text-align: center; line-height: 1.5;
}

/* F3 EN VIVO — browser frames with real screenshots */
.face-proof { background: var(--cube-face); flex-direction: column; gap: 0.5rem; padding: 1rem; }
.face-screens { display: flex; flex-direction: column; gap: 0.5rem; width: 100%; }
.browser-frame {
  border: 1px solid rgba(184,66,31,0.22); background: #fff; overflow: hidden;
}
.browser-bar {
  display: flex; gap: 0.25rem; padding: 0.3rem 0.45rem;
  background: rgba(184,66,31,0.05); border-bottom: 1px solid rgba(184,66,31,0.1);
}
.browser-bar span { width: 5px; height: 5px; border-radius: 50%; background: rgba(184,66,31,0.3); }
.browser-frame img { display: block; width: 100%; max-height: 175px; object-fit: cover; object-position: top; }

/* F5 HABLEMOS — terracotta with WhatsApp glyph */
.face-talk { background: var(--accent); }
.face-talk .face-glyph { font-size: clamp(2.8rem, 7vw, 4.5rem); color: var(--bg); }

.face[data-face="front"]  { transform: translateZ(calc(var(--s) / 2)); }
.face[data-face="back"]   { transform: rotateY(180deg) translateZ(calc(var(--s) / 2)); }
.face[data-face="right"]  { transform: rotateY(90deg) translateZ(calc(var(--s) / 2)); }
.face[data-face="left"]   { transform: rotateY(-90deg) translateZ(calc(var(--s) / 2)); }
.face[data-face="top"]    { transform: rotateX(-90deg) translateZ(calc(var(--s) / 2)); }
.face[data-face="bottom"] { transform: rotateX(90deg) translateZ(calc(var(--s) / 2)); }

/* ============================================================
   SCROLL CONTAINER — cube sections
   ============================================================ */
#scroll_container { position: relative; z-index: 1; }

section.cube-section {
  min-height: 100vh;
  display: flex; align-items: center;
  padding: 6rem calc(5rem + var(--ui-inset)) 6rem 5rem;
}
section.cube-section.card-right { justify-content: flex-end; padding: 6rem 5rem 6rem calc(5rem + var(--ui-inset)); }

/* ============================================================
   TEXT CARDS — glassmorphic on warm light
   ============================================================ */
.text-card {
  max-width: 24rem;
  padding: 2.25rem 2rem;
  background: var(--card-bg);
  border-left: 1px solid var(--card-border);
  backdrop-filter: blur(8px) saturate(120%);
  -webkit-backdrop-filter: blur(8px) saturate(120%);
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(80, 50, 20, 0.06);
}
.text-card.right {
  border-left: none;
  border-right: 1px solid var(--card-border);
  text-align: right;
}
.text-card.center { margin: 0 auto; border-left: none; border-top: 1px solid var(--card-border); text-align: center; max-width: 30rem; }

.tag { font-family: var(--font-mono); font-size: 0.62rem; letter-spacing: 0.22em; text-transform: uppercase; color: var(--accent); margin-bottom: 1.1rem; }
.text-card h1, .text-card h2 { font-family: var(--font-display); font-weight: 400; letter-spacing: 0.02em; line-height: 0.92; color: var(--ink); }
/* Cap lowered 5rem → 4.2rem: at 5rem, HERRAMIENTAS (~4.36em wide in Bebas
   Neue) ran ~21.8rem and overflowed the card's 20rem content box, orphaning
   the final S. 4.2rem keeps it at ~18.3rem with ~1.7rem margin. */
.text-card h1 { font-size: clamp(2.6rem, 6vw, 4.2rem); }
.text-card h2 { font-size: clamp(2.2rem, 5vw, 3.8rem); }
.body-text { font-size: 0.92rem; line-height: 1.7; color: var(--ink-dim); margin-top: 1.25rem; }

.h-line { width: 3rem; height: 1px; background: var(--accent); margin-bottom: 1.2rem; }

.stat-row { display: flex; gap: 2rem; margin-top: 1.8rem; flex-wrap: wrap; }
.text-card.right .stat-row { justify-content: flex-end; }
.stat { display: flex; flex-direction: column; gap: 0.15rem; }
.stat-num { font-family: var(--font-display); font-size: 2rem; color: var(--accent); line-height: 1; }
.stat-label { font-family: var(--font-mono); font-size: 0.58rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-muted); }

.cta-row { display: flex; align-items: center; gap: 0.75rem; margin-top: 1.75rem; flex-wrap: wrap; }
.text-card.right .cta-row { justify-content: flex-end; }

.cta {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.65rem 1.3rem; border: 1px solid var(--accent);
  color: var(--accent); font-family: var(--font-mono); font-size: 0.64rem;
  letter-spacing: 0.16em; text-transform: uppercase; text-decoration: none;
  cursor: pointer; transition: background 0.2s, color 0.2s;
}
.cta:hover { background: var(--accent); color: var(--bg); }
.cta svg { width: 0.7rem; height: 0.7rem; }

.status-badge { display: inline-flex; align-items: center; gap: 0.35rem; font-family: var(--font-mono); font-size: 0.6rem; letter-spacing: 0.14em; text-transform: uppercase; padding: 0.25rem 0.55rem; border: 1px solid; margin-top: 0.8rem; }
.status-badge.live { color: var(--green); border-color: var(--green); }
.status-badge.demo { color: var(--accent); border-color: var(--accent); }
.status-badge.case { color: var(--ink-muted); border-color: var(--ink-muted); }

/* ============================================================
   HUD (top-right) + scene dots (left)
   ============================================================ */
#hud {
  position: fixed; top: calc(var(--ui-inset) + 3rem); right: var(--ui-inset);
  z-index: var(--z-ui); text-align: right;
  font-family: var(--font-mono); font-size: 0.62rem; letter-spacing: 0.14em;
  color: var(--ink-muted); text-transform: uppercase;
  transition: opacity 0.4s ease;
}
#hud.fade { opacity: 0; }
.progress-bar { width: 7rem; height: 1px; background: var(--ink-muted); margin-top: 0.5rem; margin-left: auto; position: relative; overflow: hidden; opacity: 0.4; }
.progress-fill { position: absolute; inset: 0 auto 0 0; width: 0%; background: var(--accent); transition: width 0.1s linear; }
.scene-label { font-size: 0.58rem; color: var(--accent); margin-top: 0.4rem; }

#scene_strip {
  position: fixed; left: 1.5rem; top: 50%;
  translate: 0 -50%; z-index: var(--z-ui);
  display: flex; flex-direction: column; gap: 0.75rem;
  transition: opacity 0.4s ease;
}
#scene_strip.fade { opacity: 0; }
.scene-dot { position: relative; display: block; width: 5px; height: 5px; border-radius: 50%; background: var(--ink-muted); opacity: 0.4; transition: background 0.3s, scale 0.3s, opacity 0.3s; cursor: pointer; }
.scene-dot::before { content: ""; position: absolute; inset: -5px; }
.scene-dot.active { background: var(--accent); scale: 1.8; opacity: 1; }

/* Face caption (bottom center) */
#face_caption { position: fixed; bottom: var(--ui-inset); left: 50%; translate: -50% 0; z-index: var(--z-ui); text-align: center; pointer-events: none; user-select: none; transition: opacity 0.4s ease; }
#face_caption.fade { opacity: 0; }
#face_caption_num { font-family: var(--font-mono); font-size: 0.56rem; letter-spacing: 0.28em; color: var(--accent); text-transform: uppercase; margin-bottom: 0.15rem; }
#face_caption_name { font-family: var(--font-display); font-size: clamp(1.6rem, 4vw, 2.8rem); letter-spacing: 0.08em; color: var(--ink-muted); opacity: 0.4; line-height: 1; }

/* ============================================================
   POST-CUBE SECTIONS (normal scrolling)
   ============================================================ */
#post_cube { position: relative; z-index: 2; background: var(--bg); }

.standard-section { padding: 5rem 1.5rem; max-width: 1200px; margin: 0 auto; }
.section-head { margin-bottom: 3rem; }
.section-tag { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent); margin-bottom: 0.8rem; }
.section-head h2 { font-family: var(--font-display); font-size: clamp(2.2rem, 5vw, 3.8rem); font-weight: 400; letter-spacing: 0.01em; line-height: 1; color: var(--ink); }
.section-head h2 em { font-style: normal; color: var(--accent); }
.section-head .lede { font-size: 1.1rem; color: var(--ink-dim); max-width: 520px; margin-top: 1rem; }

/* Services */
.services { border-top: 1px solid rgba(184,66,31,0.1); }
.services-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2.5rem; }
.svc { padding-top: 1.5rem; border-top: 1px solid rgba(184,66,31,0.12); }
.svc-num { font-family: var(--font-mono); font-size: 0.76rem; color: var(--accent); margin-bottom: 0.6rem; }
.svc h3 { font-family: var(--font-display); font-size: 1.6rem; font-weight: 400; letter-spacing: 0.01em; margin-bottom: 0.5rem; color: var(--ink); }
.svc p { font-size: 0.95rem; color: var(--ink-dim); line-height: 1.55; }

/* Tools */
.tools { border-top: 1px solid rgba(184,66,31,0.1); }
.tools-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.2rem; }
.tool-card { padding: 2rem; background: var(--bg-2); border: 1px solid rgba(184,66,31,0.12); text-decoration: none; color: inherit; transition: transform 0.25s ease, border-color 0.25s ease; }
.tool-card:hover { transform: translateY(-4px); border-color: var(--accent); }
.tool-icon { display: inline-flex; width: 44px; height: 44px; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent); font-size: 1.1rem; margin-bottom: 1rem; }
.tool-card h3 { font-family: var(--font-display); font-size: 1.4rem; font-weight: 400; margin-bottom: 0.4rem; color: var(--ink); }
.tool-card p { font-size: 0.9rem; color: var(--ink-dim); line-height: 1.5; margin-bottom: 0.9rem; }
.tool-link { font-family: var(--font-mono); font-size: 0.72rem; color: var(--accent); }

/* Contact */
.contact-section { text-align: center; border-top: 1px solid rgba(184,66,31,0.1); padding: 6rem 1.5rem; }
.contact-section h2 { font-family: var(--font-display); font-size: clamp(2.6rem, 6vw, 4.5rem); font-weight: 400; letter-spacing: 0.02em; line-height: 1; color: var(--ink); margin-bottom: 1rem; }
.contact-section h2 em { font-style: normal; color: var(--accent); }
.contact-section p { font-size: 1.15rem; color: var(--ink-dim); max-width: 460px; margin: 0 auto 2rem; }
.contact-cta { display: inline-flex; align-items: center; gap: 0.5rem; font-family: var(--font-body); font-size: 1rem; font-weight: 500; padding: 1rem 2rem; background: var(--accent); color: var(--bg); text-decoration: none; transition: background 0.2s ease, transform 0.2s ease; }
.contact-cta:hover { background: var(--accent-dark); transform: translateY(-2px); }

/* Footer */
.site-footer { border-top: 1px solid rgba(184,66,31,0.1); padding: 2.5rem 1.5rem; }
.footer-inner { max-width: 1200px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.footer-brand { font-family: var(--font-display); font-size: 1rem; letter-spacing: 0.03em; color: var(--ink-dim); }
.footer-links { display: flex; gap: 0.6rem; }
.footer-links a { display: inline-flex; width: 36px; height: 36px; align-items: center; justify-content: center; border: 1px solid rgba(184,66,31,0.15); color: var(--ink-dim); text-decoration: none; transition: all 0.2s ease; }
.footer-links a:hover { color: var(--accent); border-color: var(--accent); }

/* ============================================================
   REVEAL ANIMATIONS
   ============================================================ */
.reveal { opacity: 0; translate: 0 var(--reveal-offset); transition: opacity var(--reveal-duration) ease, translate var(--reveal-duration) ease; }
.reveal.is-h { translate: 0 1rem; transition-delay: 0.08s; }
.reveal.is-body { transition-delay: 0.2s; }
.reveal.is-stat { transition-delay: 0.3s; }
.reveal.is-cta { transition-delay: 0.35s; }
.reveal.is-line { opacity: 0; scale: 0 1; transition: opacity 0.4s ease, scale 0.4s ease; }
.reveal.visible { opacity: 1; translate: 0 0; scale: 1 1; }

/* ============================================================
   REDUCED MOTION — static fallback
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  #scene, #hud, #scene_strip, #face_caption { display: none !important; }
  #cube_stage { height: auto; }   /* no empty runway when cube is hidden */
  section.cube-section { min-height: auto; padding: 3rem 1.5rem; justify-content: flex-start !important; }
  .text-card { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--bg-2); box-shadow: none; max-width: 100%; }
  .reveal { opacity: 1; translate: 0 0; scale: 1 1; }
}

/* ============================================================
   RESPONSIVE — sticky scroll-pinned cube on mobile
   Desktop keeps the fixed-cube-behind-cards composition. On phones
   the cube pins inside a tall stage and rotates through its faces as
   the stage scrolls past; once past, it releases into a clean stacked
   reading flow. position:sticky sidesteps the iOS fixed/URL-bar hell.
   ============================================================ */
@media (max-width: 900px) {
  /* THE STAGE: a tall runway. #scene sticks inside it for one viewport
     and rotates the cube as the runway scrolls underneath. */
  #cube_stage {
    position: relative;
    height: 360vh;            /* runway length → controls spin pacing */
  }
  #scene {
    position: sticky;
    top: 0;            /* the non-auto edge sticky needs to pin */
    height: 100vh;     /* fallback */
    height: 100dvh;    /* respect iOS dynamic URL bar */
  }

  /* Gecko corrupts preserve-3d descendants while their containing scene is
     sticky. Firefox does not need the iOS URL-bar workaround, so keep its
     scene fixed and let the same stage scroll calculation drive the cube. */
  @supports (-moz-appearance: none) {
    #scene { position: fixed; }
  }

  /* Big, prominent cube — this is the hero, not a stamp */
  #cube {
    --s: min(82vw, 46vh, 420px);   /* fallback for browsers without dvh */
    --s: min(82vw, 46dvh, 420px);
  }

  /* The proof face crams two screenshots; shrink so they fit a smaller face */
  .face-proof { padding: 0.6rem; }
  .browser-frame img { max-height: 118px; }

  /* BELOW THE STAGE: cards stack as normal reading flow. They no longer
     overlay the cube, so drop the glass/blur tax entirely. */
  section.cube-section {
    min-height: auto;
    display: block;
    padding: 2.5rem 1.5rem;
  }
  section.cube-section.card-right { justify-content: flex-start; padding: 2.5rem 1.5rem; }
  .text-card, .text-card.right, .text-card.center {
    max-width: 100%;
    padding: 1.5rem 1.25rem;
    text-align: left;
    background: var(--bg-2);
    backdrop-filter: none; -webkit-backdrop-filter: none;
    box-shadow: none;
    border-left: 1px solid var(--card-border);
    border-right: none;
  }
  .text-card.right .cta-row, .text-card.right .stat-row { justify-content: flex-start; }

  #hud { top: 4.5rem; right: 1rem; }
  #scene_strip { display: none; }
  #face_caption { display: none; }
  .services-grid, .tools-grid { grid-template-columns: 1fr; gap: 1.5rem; }
  .site-nav a:not(.nav-cta) { display: none; }
}
