/* ============================================================
   STUDIO-fm — main.css
   Custom layer on top of Tailwind (CDN).
   Everything Tailwind can't express: loader, cursor, grid,
   marquee, reveal states, RTL fixes, nav behaviour.
   ============================================================ */

:root {
  --accent: #e63946;
  --accent-dark: #cc1f2e;
  --gold: #fbbf24;
  --ink-50: #f7f7f8;
  --ink-950: #0a0a0a;
  --nav-h: 76px;
  --ease: cubic-bezier(0.76, 0, 0.24, 1);
}

/* ---------- Base ---------- */

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

html.is-loading,
html.menu-open {
  overflow: hidden;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
}

::selection {
  background: var(--accent);
  color: #fff;
}

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #d6d6da;
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: content-box;
}
html.dark ::-webkit-scrollbar-thumb { background: #3f3f46; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); background-clip: content-box; }

/* Arabic typography */
html[lang="ar"] body { font-family: 'Cairo', 'Inter', system-ui, sans-serif; }
html[lang="ar"] .font-display,
html[lang="ar"] h1,
html[lang="ar"] h2,
html[lang="ar"] h3 { font-family: 'Cairo', 'Space Grotesk', sans-serif; letter-spacing: 0; }
html[lang="ar"] .font-mono { font-family: 'Cairo', 'JetBrains Mono', monospace; }

/* Arabic glyphs are taller than Latin ones: the hero headline needs a smaller
   size and a looser line-height, or the four lines overflow the viewport and
   push the badge under the nav. */
html[lang="ar"] h1 {
  font-size: clamp(2.25rem, 7vw, 6.5rem);
  line-height: 1.1;
}

/* Keep phone numbers / latin bits readable inside RTL */
[dir="rtl"] [dir="ltr"] { display: inline-block; unicode-bidi: embed; }

/* ---------- Hero ---------- */

/* Keep hero content clear of the fixed nav in every language, even when a
   translation runs taller than the English original. */
#hero {
  padding-top: calc(var(--nav-h) + 24px);
  padding-bottom: 3rem;
}

/* On short viewports the scroll hint collides with the CTA buttons.
   Needs the #hero prefix to outrank Tailwind's .flex utility. */
@media (max-height: 900px) {
  #hero .hero-scroll { display: none; }
}

/* ---------- Decorative grid ---------- */

.bg-grid {
  background-image:
    linear-gradient(to right, currentColor 1px, transparent 1px),
    linear-gradient(to bottom, currentColor 1px, transparent 1px);
  background-size: 64px 64px;
  background-position: center;
  -webkit-mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
          mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
}

/* ---------- Loader ---------- */

.loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink-950);
  color: var(--ink-50);
  transition: opacity 0.8s var(--ease), visibility 0.8s var(--ease);
}

.loader.is-done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-content {
  width: min(420px, 78vw);
  text-align: center;
}

.loader-counter {
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(2.5rem, 9vw, 4.5rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.04em;
}

.loader-text {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: clamp(1.1rem, 3.5vw, 1.5rem);
  letter-spacing: 0.02em;
  margin-top: 1.25rem;
}

.loader-bar {
  height: 2px;
  width: 100%;
  margin-top: 1.5rem;
  background: rgba(247, 247, 248, 0.12);
  overflow: hidden;
  border-radius: 999px;
}

.loader-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.25s linear;
}

.loader-status {
  margin-top: 0.9rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: #6b6b75;
  min-height: 1em;
}

/* ---------- Custom cursor (desktop pointers only) ---------- */

.cursor-dot,
.cursor-ring {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 90;
  pointer-events: none;
  border-radius: 999px;
  opacity: 0;
  will-change: transform;
}

.cursor-dot {
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  background: var(--accent);
  transition: opacity 0.3s ease, transform 0.15s ease;
}

.cursor-ring {
  width: 38px;
  height: 38px;
  margin: -19px 0 0 -19px;
  border: 1px solid rgba(10, 10, 10, 0.35);
  transition: opacity 0.3s ease, width 0.3s var(--ease), height 0.3s var(--ease),
              margin 0.3s var(--ease), border-color 0.3s ease, background-color 0.3s ease;
}

html.dark .cursor-ring { border-color: rgba(247, 247, 248, 0.35); }

html.cursor-ready .cursor-dot,
html.cursor-ready .cursor-ring { opacity: 1; }

html.cursor-ready.cursor-hover .cursor-ring {
  width: 68px;
  height: 68px;
  margin: -34px 0 0 -34px;
  border-color: var(--accent);
  background: rgba(230, 57, 70, 0.08);
}

/* The dot's transform is driven by JS each frame, so fade it instead of scaling. */
html.cursor-ready.cursor-hover .cursor-dot { opacity: 0; }

/* Hide native cursor only where a custom one is actually drawn */
@media (hover: hover) and (pointer: fine) {
  html.cursor-ready,
  html.cursor-ready a,
  html.cursor-ready button { cursor: none; }
  html.cursor-ready input,
  html.cursor-ready textarea,
  html.cursor-ready select { cursor: auto; }
}

@media (hover: none), (pointer: coarse) {
  .cursor-dot, .cursor-ring { display: none; }
}

/* ---------- Scroll progress ---------- */

.scroll-progress {
  position: fixed;
  top: 0;
  inset-inline: 0;
  height: 2px;
  z-index: 60;
  background: transparent;
  pointer-events: none;
}

.scroll-progress > span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  transform-origin: left center;
}

[dir="rtl"] .scroll-progress > span { margin-inline-start: auto; }

/* ---------- Nav ---------- */

#nav { will-change: transform; }

#nav.is-scrolled {
  background: rgba(247, 247, 248, 0.72);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid rgba(10, 10, 10, 0.07);
}

html.dark #nav.is-scrolled {
  background: rgba(10, 10, 10, 0.7);
  border-bottom-color: rgba(247, 247, 248, 0.08);
}

#nav.is-hidden { transform: translateY(-110%); }

.nav-link {
  position: relative;
  padding-bottom: 2px;
}

.nav-link::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: right center;
  transition: transform 0.4s var(--ease);
}

.nav-link:hover::after,
.nav-link.is-active::after {
  transform: scaleX(1);
  transform-origin: left center;
}

.nav-link.is-active { color: var(--accent); }

/* Language menu */
#langMenu.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.lang-opt.is-current {
  color: var(--accent);
  font-weight: 600;
}

/* Burger → X */
#menuToggle span { transform-origin: center; }
#menuToggle.is-open #menuLine1 { transform: translateY(4px) rotate(45deg); }
#menuToggle.is-open #menuLine2 { transform: translateY(-4px) rotate(-45deg); }

/* Mobile menu */
#mobileMenu.is-open { transform: translateX(0); }

.mobile-link {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.5s ease, transform 0.5s var(--ease);
}

#mobileMenu.is-open .mobile-link {
  opacity: 1;
  transform: translateY(0);
}

#mobileMenu.is-open .mobile-link:nth-child(1) { transition-delay: 0.12s; }
#mobileMenu.is-open .mobile-link:nth-child(2) { transition-delay: 0.18s; }
#mobileMenu.is-open .mobile-link:nth-child(3) { transition-delay: 0.24s; }
#mobileMenu.is-open .mobile-link:nth-child(4) { transition-delay: 0.30s; }
#mobileMenu.is-open .mobile-link:nth-child(5) { transition-delay: 0.36s; }

/* ---------- Marquee ---------- */

#marquee { will-change: transform; }
#marquee:hover { animation-play-state: paused; }

.marquee-item {
  display: inline-flex;
  align-items: center;
  gap: 2.5rem;
  padding-inline: 1.25rem;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: clamp(1.5rem, 4vw, 2.75rem);
  letter-spacing: -0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

html[lang="ar"] .marquee-item { text-transform: none; font-family: 'Cairo', sans-serif; }

.marquee-item .dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
  flex: none;
}

.marquee-item.is-outline {
  color: transparent;
  -webkit-text-stroke: 1px #b3b3b9;
}

html.dark .marquee-item.is-outline { -webkit-text-stroke-color: #52525b; }

/* ---------- Work / projects ---------- */

.project-img { background: linear-gradient(135deg, #eeeef0, #d6d6da); }
html.dark .project-img { background: linear-gradient(135deg, #18181b, #27272a); }

.project-img img { transition: filter 0.6s ease; }
.project:hover .project-img img { filter: saturate(1.15) contrast(1.03); }

/* ---------- Process ---------- */

.process-step { transition: padding-inline-start 0.4s var(--ease), color 0.4s ease; }
@media (min-width: 768px) {
  .process-step:hover { padding-inline-start: 1.25rem; }
}

/* ---------- Quote ticket (pricing) ---------- */

.ticket {
  position: relative;
  border-radius: 22px;
  padding: 2rem 1.75rem 1.5rem;
  font-family: 'JetBrains Mono', monospace;
  border: 1px solid rgba(10, 10, 10, 0.12);
  background:
    radial-gradient(120% 90% at 15% 0%, rgba(230, 57, 70, 0.10), transparent 60%),
    radial-gradient(110% 90% at 95% 100%, rgba(251, 191, 36, 0.10), transparent 60%),
    #ffffff;
  box-shadow: 0 30px 60px -30px rgba(10, 10, 10, 0.35);
}

html.dark .ticket {
  border-color: rgba(247, 247, 248, 0.14);
  background:
    radial-gradient(120% 90% at 15% 0%, rgba(230, 57, 70, 0.16), transparent 60%),
    radial-gradient(110% 90% at 95% 100%, rgba(251, 191, 36, 0.10), transparent 60%),
    #131316;
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.8);
}

html[lang="ar"] .ticket { font-family: 'Cairo', 'JetBrains Mono', monospace; }

.ticket-head { text-align: center; padding-bottom: 1.25rem; }

.ticket-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #888891;
  margin-bottom: 1.5rem;
}

.ticket-brand {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
}

.ticket-tag {
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #6b6b75;
  margin-top: 0.6rem;
  line-height: 1.7;
}

html.dark .ticket-tag { color: #888891; }

.ticket-body {
  border-top: 1px dashed rgba(10, 10, 10, 0.2);
  padding-top: 1.5rem;
  min-height: 288px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

html.dark .ticket-body { border-top-color: rgba(247, 247, 248, 0.2); }

/* Steps */
.q-step { display: none; }
.q-step.is-active { display: block; animation: qFade 0.45s var(--ease) both; }

@keyframes qFade {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.q-intro {
  font-size: 0.85rem;
  line-height: 1.85;
  color: #52525b;
  margin-bottom: 1.75rem;
  text-align: center;
}

html.dark .q-intro { color: #b3b3b9; }

.q-label {
  font-size: 0.62rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: #888891;
  text-align: center;
  margin-bottom: 0.75rem;
}

.q-amount {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: clamp(2.25rem, 7vw, 3.25rem);
  line-height: 1;
  text-align: center;
  letter-spacing: -0.03em;
}

.q-amount-alt {
  text-align: center;
  font-size: 0.78rem;
  color: #888891;
  margin-top: 0.5rem;
}

.q-tier {
  text-align: center;
  font-size: 0.8rem;
  line-height: 1.7;
  color: var(--accent);
  margin: 1.1rem auto 1.75rem;
  min-height: 2.7em;
  max-width: 34ch;
}

/* Range slider */
.q-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  outline: none;
  cursor: pointer;
  background: linear-gradient(to right,
    var(--accent) 0%, var(--accent) var(--q-progress, 25%),
    rgba(10, 10, 10, 0.14) var(--q-progress, 25%), rgba(10, 10, 10, 0.14) 100%);
}

html.dark .q-range {
  background: linear-gradient(to right,
    var(--accent) 0%, var(--accent) var(--q-progress, 25%),
    rgba(247, 247, 248, 0.16) var(--q-progress, 25%), rgba(247, 247, 248, 0.16) 100%);
}

[dir="rtl"] .q-range {
  background: linear-gradient(to left,
    var(--accent) 0%, var(--accent) var(--q-progress, 25%),
    rgba(10, 10, 10, 0.14) var(--q-progress, 25%), rgba(10, 10, 10, 0.14) 100%);
}

html.dark [dir="rtl"] .q-range,
[dir="rtl"] html.dark .q-range {
  background: linear-gradient(to left,
    var(--accent) 0%, var(--accent) var(--q-progress, 25%),
    rgba(247, 247, 248, 0.16) var(--q-progress, 25%), rgba(247, 247, 248, 0.16) 100%);
}

.q-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  border: 4px solid #fff;
  box-shadow: 0 3px 12px rgba(230, 57, 70, 0.5);
  cursor: grab;
  transition: transform 0.2s ease;
}

html.dark .q-range::-webkit-slider-thumb { border-color: #131316; }
.q-range::-webkit-slider-thumb:active { transform: scale(1.15); cursor: grabbing; }

.q-range::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  border: 4px solid #fff;
  box-shadow: 0 3px 12px rgba(230, 57, 70, 0.5);
  cursor: grab;
}

html.dark .q-range::-moz-range-thumb { border-color: #131316; }

.q-scale {
  display: flex;
  justify-content: space-between;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  color: #888891;
  margin-top: 0.85rem;
  margin-bottom: 1.75rem;
}

/* Buttons */
.ticket-btn {
  display: block;
  width: 100%;
  padding: 1rem 1.25rem;
  border-radius: 999px;
  background: var(--accent);
  color: #f7f7f8;
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  border: 0;
  cursor: pointer;
  transition: background 0.3s ease, transform 0.2s ease;
}

html[lang="ar"] .ticket-btn { letter-spacing: 0; font-size: 0.9rem; }

.ticket-btn:hover { background: var(--gold); color: #0a0a0a; }
.ticket-btn:active { transform: scale(0.98); }

.ticket-link {
  display: block;
  width: 100%;
  margin-top: 1rem;
  padding: 0.5rem;
  background: none;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: #888891;
  transition: color 0.3s ease;
}

.ticket-link:hover { color: var(--accent); }

/* Channel toggle */
.q-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 1.1rem;
}

.q-toggle button {
  padding: 0.75rem;
  border-radius: 999px;
  border: 1px solid rgba(10, 10, 10, 0.18);
  background: none;
  color: inherit;
  font-family: inherit;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.3s ease;
}

html.dark .q-toggle button { border-color: rgba(247, 247, 248, 0.18); }
.q-toggle button.is-on { background: var(--accent); border-color: var(--accent); color: #f7f7f8; }

.q-input {
  width: 100%;
  padding: 0.85rem 1.15rem;
  margin-bottom: 0.6rem;
  border-radius: 999px;
  border: 1px solid rgba(10, 10, 10, 0.18);
  background: rgba(10, 10, 10, 0.03);
  color: inherit;
  font-family: inherit;
  font-size: 0.82rem;
  transition: border-color 0.3s ease;
}

html.dark .q-input {
  border-color: rgba(247, 247, 248, 0.18);
  background: rgba(247, 247, 248, 0.04);
}

.q-input:focus { outline: none; border-color: var(--accent); }
.q-input::placeholder { color: #888891; }
.q-input.field-error { border-color: var(--accent) !important; }

/* "Received" stamp */
.q-stamp {
  display: block;
  width: max-content;
  margin: 0 auto 1.5rem;
  padding: 0.6rem 1.5rem;
  border: 2px solid #22c55e;
  border-radius: 8px;
  color: #22c55e;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  transform: rotate(-6deg);
  opacity: 0.9;
}

.ticket-note {
  border-top: 1px dashed rgba(10, 10, 10, 0.2);
  margin-top: 1.5rem;
  padding-top: 1.1rem;
  font-size: 0.62rem;
  line-height: 1.8;
  letter-spacing: 0.06em;
  text-align: center;
  color: #888891;
}

html.dark .ticket-note { border-top-color: rgba(247, 247, 248, 0.2); }

/* ---------- Forms ---------- */

#contactForm input,
#contactForm textarea,
#contactForm select {
  color: inherit;
  font: inherit;
}

#contactForm input::placeholder,
#contactForm textarea::placeholder {
  color: currentColor;
  opacity: 0.45;
}

#contactForm select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888891' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1.25rem center;
  background-size: 18px;
  padding-inline-end: 3rem;
}

[dir="rtl"] #contactForm select { background-position: left 1.25rem center; }

#contactForm option { background: #f7f7f8; color: #0a0a0a; }

.field-error {
  border-color: var(--accent) !important;
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.form-feedback {
  font-size: 0.8rem;
  text-align: center;
  min-height: 1.2em;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.form-feedback.is-visible { opacity: 1; }
.form-feedback.is-error { color: var(--accent); }
.form-feedback.is-ok { color: #22c55e; }

/* ---------- Floating WhatsApp ---------- */

#whatsappFloat { transition: transform 0.4s var(--ease), opacity 0.4s ease; }
#whatsappFloat.is-tucked { transform: translateY(140%); opacity: 0; }

/* ---------- Back to top ---------- */

.to-top {
  position: fixed;
  bottom: 1.5rem;
  inset-inline-start: 1.5rem;
  z-index: 40;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid rgba(10, 10, 10, 0.15);
  background: rgba(247, 247, 248, 0.8);
  backdrop-filter: blur(10px);
  color: #0a0a0a;
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s var(--ease), border-color 0.3s ease, color 0.3s ease;
}

html.dark .to-top {
  border-color: rgba(247, 247, 248, 0.18);
  background: rgba(10, 10, 10, 0.7);
  color: #f7f7f8;
}

.to-top.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.to-top:hover { border-color: var(--accent); color: var(--accent); }

/* On phones it floats over form labels, and the thumb is already near the top. */
@media (max-width: 640px) {
  .to-top { display: none; }
}

/* ---------- Reveal states (only when GSAP is available) ---------- */

html.anim .hero-line,
html.anim .hero-reveal { opacity: 0; }

html.anim .project,
html.anim .service,
html.anim .process-step,
html.anim .ticket,
html.anim .reveal-up { opacity: 0; }

/* Safety net: if JS dies after boot, never leave the page blank */
html.anim.reveal-fallback .hero-line,
html.anim.reveal-fallback .hero-reveal,
html.anim.reveal-fallback .project,
html.anim.reveal-fallback .service,
html.anim.reveal-fallback .process-step,
html.anim.reveal-fallback .ticket,
html.anim.reveal-fallback .reveal-up {
  opacity: 1 !important;
  transform: none !important;
}

/* ---------- Motion preferences ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .cursor-dot, .cursor-ring { display: none; }
  #bg3d { display: none; }
}

/* ---------- Print ---------- */

@media print {
  .loader, #nav, #mobileMenu, #whatsappFloat, .to-top,
  .cursor-dot, .cursor-ring, #bg3d, .scroll-progress { display: none !important; }
  body { background: #fff !important; color: #000 !important; }
}

/* ---------- Barcelona collection (swipe row on mobile) ---------- */

.bcn-track { scrollbar-width: none; -webkit-overflow-scrolling: touch; scroll-padding-inline: 1.5rem; }
.bcn-track::-webkit-scrollbar { display: none; }
