/* =========================================================================
   Lofiest - site.css
   Shared design system + chrome (background, header, footer, glass, buttons,
   language switcher). Loaded by every page via base.html.
   ========================================================================= */

/* ---- Reset ---- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* ---- Registered accent properties ----
   Registering the accent vars as <color> lets the BROWSER interpolate them:
   one 6s transition on :root and every gradient/glow that consumes the vars
   glides instead of snapping - and interactive transitions (buttons) no
   longer need to share the slow ambient timing. */
@property --accent-primary   { syntax: '<color>'; inherits: true; initial-value: #FFB84D; }
@property --accent-secondary { syntax: '<color>'; inherits: true; initial-value: #FFD699; }
@property --accent-glow      { syntax: '<color>'; inherits: true; initial-value: rgba(255, 184, 77, 0.30); }

/* ---- Design tokens ---- */
:root {
    /* Surfaces */
    --bg-primary: #0a0a0f;
    --bg-elevated: #12121a;
    --bg-raised: #16161f;

    /* Glass */
    --glass-bg: rgba(255, 255, 255, 0.035);
    --glass-bg-strong: rgba(255, 255, 255, 0.06);
    --glass-border: rgba(255, 255, 255, 0.09);
    --glass-border-strong: rgba(255, 255, 255, 0.16);
    --glass-shadow: rgba(0, 0, 0, 0.35);

    /* Brand accent - PINNED amber. JS drifts it subtly (reduced-motion aware)
       and the Mood Ring retunes it to the playing track's mood. */
    --accent-primary: #FFB84D;
    --accent-secondary: #FFD699;
    --accent-glow: rgba(255, 184, 77, 0.30);
    --accent-cool: #8B7BD8; /* supporting dusk tone, echoes the app screenshots */

    /* Text (muted raised to pass WCAG AA on the dark bg) */
    --text-primary: #f8fafc;
    --text-secondary: rgba(248, 250, 252, 0.72);
    --text-muted: rgba(248, 250, 252, 0.56);

    /* Spacing scale */
    --sp-1: 0.25rem;  --sp-2: 0.5rem;   --sp-3: 0.75rem;  --sp-4: 1rem;
    --sp-5: 1.5rem;   --sp-6: 2rem;     --sp-8: 3rem;     --sp-10: 4rem;
    --sp-12: 6rem;    --sp-16: 8rem;

    /* Radius */
    --r-sm: 10px; --r-md: 14px; --r-lg: 20px; --r-xl: 28px; --r-full: 999px;

    /* Motion - a small easing palette instead of one curve for everything */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);            /* legacy/general state changes */
    --ease-lofi: cubic-bezier(0.22, 1, 0.36, 1);     /* entrances, reveals, settles */
    --ease-snap: cubic-bezier(0.2, 0, 0, 1);         /* buttons, hovers - quick, confident */
    --ease-exit: cubic-bezier(0.55, 0, 1, 0.45);     /* things leaving */
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);/* tiny overshoot, <=300ms only */
    --ease-drift: cubic-bezier(0.37, 0, 0.63, 1);    /* ambient loops (sine) */

    /* Layout */
    --maxw: 1200px;
    --header-h: 84px;
}

/* The accent world fades over 6s - ONLY here. Interactive elements keep their
   own fast transitions; everything consuming the vars glides automatically. */
:root {
    transition: --accent-primary 6s var(--ease-drift),
                --accent-secondary 6s var(--ease-drift),
                --accent-glow 6s var(--ease-drift);
}

html { scroll-behavior: smooth; scroll-padding-top: 90px; }

body {
    font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

[dir="rtl"] body {
    font-family: 'Vazirmatn', 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
}

a { color: inherit; }
img, svg, video { display: block; max-width: 100%; }
:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 3px;
    border-radius: 4px;
}

/* Skip link */
.skip-link {
    position: absolute;
    left: 50%;
    top: -60px;
    transform: translateX(-50%);
    z-index: 2000;
    padding: 0.6rem 1.2rem;
    background: var(--accent-primary);
    color: #0a0a0f;
    font-weight: 600;
    border-radius: var(--r-sm);
    transition: top 0.2s var(--ease);
}
.skip-link:focus { top: 12px; }

/* Shared icon sizing (inline SVG sprite <use>) */
.icon { width: 20px; height: 20px; stroke: currentColor; fill: none;
        stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---- Animated background ---- */
.bg-wrapper { position: fixed; inset: 0; z-index: -1; overflow: hidden; }
.bg-gradient {
    position: absolute; width: 150%; height: 150%; top: -25%; left: -25%;
    animation: bgMove 24s ease-in-out infinite;
}
.bg-gradient-layer { position: absolute; inset: 0; transition: opacity 6s ease-in-out; }
.bg-gradient-layer.layer-a { opacity: 1; }
.bg-gradient-layer.layer-b { opacity: 0; }

@keyframes bgMove {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(2%, 2%) rotate(1deg); }
    50% { transform: translate(-1%, 3%) rotate(-1deg); }
    75% { transform: translate(3%, -2%) rotate(0.5deg); }
}

.bg-noise {
    position: absolute; inset: 0; pointer-events: none; opacity: 0.035;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.bg-grid {
    position: absolute; inset: 0; pointer-events: none; opacity: 0.4;
    -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 20%, transparent 75%);
    mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 20%, transparent 75%);
    background-image:
        linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
    background-size: 64px 64px;
}

/* Coprime durations: the three orbs never repeat the same composite pattern */
.orb { position: absolute; border-radius: 50%; filter: blur(80px);
       animation: float 19s var(--ease-drift) infinite; }
.orb-1 { width: 440px; height: 440px; background: var(--accent-primary); opacity: 0.13; top: 6%; left: 8%; }
.orb-2 { width: 320px; height: 320px; background: var(--accent-primary); opacity: 0.08; bottom: 14%; right: 12%; animation-delay: -6s; animation-duration: 23s; }
.orb-3 { width: 260px; height: 260px; background: var(--accent-cool); opacity: 0.05; top: 48%; left: 52%; animation-delay: -12s; animation-duration: 29s; }

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(34px, -30px) scale(1.06); }
    66% { transform: translate(-22px, 22px) scale(0.94); }
}

/* ---- Layout ---- */
.container { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--sp-6); }
.section { padding: var(--sp-12) 0; }
/* Eyebrows are bare uppercase by default; the pill treatment is reserved for
   the hero so the device keeps its meaning. */
.eyebrow {
    display: inline-flex; align-items: center; gap: 0.5rem;
    font-size: 0.8rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase;
    color: var(--accent-primary);
}
.eyebrow--pill {
    padding: 0.35rem 0.85rem; border: 1px solid var(--glass-border);
    border-radius: var(--r-full); background: var(--glass-bg);
}
.section-head { text-align: center; max-width: 640px; margin: 0 auto var(--sp-8); }
.section-head h2 {
    font-family: 'Sora', sans-serif; font-weight: 800;
    font-size: clamp(1.8rem, 3.8vw, 2.5rem); line-height: 1.15; letter-spacing: -0.01em;
    margin: var(--sp-4) 0 var(--sp-3);
    color: var(--text-primary);
}
.section-head p { color: var(--text-secondary); font-size: 1.05rem; }
.brand-name { font-family: 'Sora', sans-serif; font-weight: 800; }
.text-accent {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
   
}

/* ---- Glass card ---- */
.glass-card {
    background: var(--glass-bg); border: 1px solid var(--glass-border);
    border-radius: var(--r-lg); padding: var(--sp-6);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    transition: transform 0.3s var(--ease), border-color 0.3s var(--ease), background-color 0.3s var(--ease);
}
/* Hover lift is an affordance - only genuinely clickable cards get it. */
@media (hover: hover) {
    .glass-card.is-link:hover, a.glass-card:hover {
        transform: translateY(-4px); border-color: var(--glass-border-strong);
        background: var(--glass-bg-strong);
    }
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.55rem;
    padding: 0.9rem 1.7rem; border-radius: var(--r-md);
    font-family: inherit; font-size: 1rem; font-weight: 600; text-decoration: none;
    cursor: pointer; border: 1px solid transparent; white-space: nowrap;
    transition: transform 0.2s var(--ease-snap), background-color 0.2s var(--ease-snap), border-color 0.2s var(--ease-snap), filter 0.2s var(--ease-snap);
    -webkit-user-select: none; user-select: none;
}
.btn .icon { width: 18px; height: 18px; }
.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: #0a0a0f;
}
.btn-primary:hover { transform: translateY(-2px); filter: brightness(1.06); }
.btn-ghost {
    background: var(--glass-bg); border-color: var(--glass-border); color: var(--text-primary);
    backdrop-filter: blur(10px);
}
.btn-ghost:hover { background: var(--glass-bg-strong); border-color: var(--glass-border-strong); transform: translateY(-2px); }
.btn-lg { padding: 1.05rem 2rem; font-size: 1.05rem; }

/* ---- Header ---- */
.site-header {
    position: sticky; top: 1rem; z-index: 100; margin-top: 1rem;
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.75rem 1.25rem; border-radius: var(--r-md);
    border: 1px solid transparent;
    transition: background-color 0.35s var(--ease), border-color 0.35s var(--ease);
    -webkit-user-select: none; user-select: none;
}
.site-header.scrolled {
    background: rgba(12, 12, 18, 0.72); backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px);
    border-color: var(--glass-border);
}
.logo { display: flex; align-items: center; gap: 0.7rem; text-decoration: none; }
.logo-video-wrapper { position: relative; width: 48px; height: 48px; flex: none; }
.logo-video { width: 48px; height: 48px; border-radius: 12px; object-fit: cover; opacity: 0; transition: opacity 0.5s var(--ease); }
.logo-video.loaded { opacity: 1; }
.logo-video-placeholder {
    position: absolute; inset: 0; background: var(--glass-bg); border: 1px solid var(--glass-border);
    border-radius: 12px; display: flex; align-items: center; justify-content: center; transition: opacity 0.5s ease-out;
}
.logo-video-placeholder.hidden { opacity: 0; pointer-events: none; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--glass-border); border-top-color: var(--accent-primary); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.logo-text {
    font-family: 'Sora', sans-serif; font-size: 1.5rem; font-weight: 800; white-space: nowrap;
    background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}

/* Dust motes - stillness made visible. Used by the hero and the 404 page. */
.motes { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.motes i {
    position: absolute; display: block; border-radius: 50%;
    width: 3px; height: 3px; opacity: 0;
    background: radial-gradient(circle, var(--accent-secondary), transparent 70%);
    animation: mote-drift var(--mote-t, 26s) linear infinite;
    animation-delay: var(--mote-d, 0s);
}
.motes i:nth-child(1) { left: 12%; top: 78%; --mote-t: 24s; }
.motes i:nth-child(2) { left: 28%; top: 88%; --mote-t: 31s; --mote-d: -8s; width: 2px; height: 2px; }
.motes i:nth-child(3) { left: 44%; top: 82%; --mote-t: 27s; --mote-d: -15s; filter: blur(1px); width: 4px; height: 4px; }
.motes i:nth-child(4) { left: 58%; top: 92%; --mote-t: 35s; --mote-d: -4s; }
.motes i:nth-child(5) { left: 72%; top: 80%; --mote-t: 29s; --mote-d: -20s; width: 2px; height: 2px; filter: blur(1px); }
.motes i:nth-child(6) { left: 86%; top: 86%; --mote-t: 33s; --mote-d: -12s; }
@keyframes mote-drift {
    0%   { transform: translate(0, 0); opacity: 0; }
    8%   { opacity: 0.35; }
    92%  { opacity: 0.25; }
    100% { transform: translate(4vw, -70vh); opacity: 0; }
}
.logo-t {
    display: inline-block; max-width: 0; opacity: 0; overflow: hidden; vertical-align: top;
    background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
    animation: reveal-t 2.8s var(--ease) 1.5s both;
}
@keyframes reveal-t {
    0% { max-width: 0; opacity: 0; } 20% { max-width: 0.7em; opacity: 1; }
    65% { max-width: 0.7em; opacity: 1; } 100% { max-width: 0; opacity: 0; }
}

.nav { display: flex; align-items: center; gap: 1.5rem; }
.nav-links { display: flex; align-items: center; gap: 1.4rem; }
.nav-links a {
    display: inline-flex; align-items: center; gap: 0.4rem; color: var(--text-secondary);
    text-decoration: none; font-size: 0.92rem; font-weight: 500; transition: color 0.2s; position: relative;
}
.nav-links a:hover { color: var(--text-primary); }
.nav-links a .icon { width: 17px; height: 17px; }
.nav-cta { padding: 0.55rem 1.1rem; font-size: 0.9rem; }

/* Language switcher */
.lang-switcher { position: relative; }
.lang-toggle {
    display: inline-flex; align-items: center; gap: 0.35rem; background: none; border: none;
    color: var(--text-secondary); font-family: inherit; font-size: 0.9rem; cursor: pointer; padding: 0.3rem;
    transition: color 0.2s;
}
.lang-toggle:hover { color: var(--text-primary); }
.lang-chevron { width: 14px; height: 14px; transition: transform 0.2s; }
.lang-switcher.open .lang-chevron { transform: rotate(180deg); }
.lang-dropdown {
    position: absolute; top: calc(100% + 10px); inset-inline-end: 0; min-width: 160px;
    background: rgba(18,18,26,0.96); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border); border-radius: var(--r-md); padding: 0.4rem;
    opacity: 0; visibility: hidden; transform: translateY(-8px); transition: all 0.2s var(--ease);
    z-index: 1000;
}
.lang-switcher.open .lang-dropdown { opacity: 1; visibility: visible; transform: translateY(0); }
.lang-option {
    display: block; width: 100%; padding: 0.55rem 0.9rem; background: none; border: none;
    color: var(--text-secondary); font-family: inherit; font-size: 0.9rem; text-align: start;
    cursor: pointer; border-radius: 8px; transition: all 0.15s;
}
.lang-option:hover { background: rgba(255,255,255,0.06); color: var(--text-primary); }
.lang-option.active { color: var(--accent-primary); background: rgba(255,255,255,0.04); }

/* Mobile nav toggle (hidden on desktop) */
.nav-toggle { display: none; background: var(--glass-bg); border: 1px solid var(--glass-border);
    color: var(--text-primary); width: 42px; height: 42px; border-radius: var(--r-sm); cursor: pointer;
    align-items: center; justify-content: center; }

/* ---- Footer ---- */
.site-footer { border-top: 1px solid var(--glass-border); margin-top: var(--sp-12); padding: var(--sp-10) 0 var(--sp-6); }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: var(--sp-6); margin-bottom: var(--sp-8); }
.footer-brand .logo-text { font-size: 1.3rem; }
/* the site is still quietly playing, all the way down */
.footer-eq { display: inline-flex; align-items: flex-end; gap: 2.5px; height: 12px;
    margin-inline-start: 0.6rem; }
.footer-eq i { width: 3px; border-radius: 2px; opacity: 0.75;
    background: linear-gradient(var(--accent-primary), var(--accent-secondary)); }
.footer-eq i:nth-child(1) { height: 6px; }  .footer-eq i:nth-child(2) { height: 10px; }
.footer-eq i:nth-child(3) { height: 7px; }  .footer-eq i:nth-child(4) { height: 12px; }
.footer-eq i:nth-child(5) { height: 8px; }
@media (prefers-reduced-motion: no-preference) {
    .footer-eq i { transform-origin: bottom; animation: footer-eq 2.8s var(--ease-drift) infinite; }
    .footer-eq i:nth-child(2) { animation-delay: -0.5s; }
    .footer-eq i:nth-child(3) { animation-delay: -1.1s; }
    .footer-eq i:nth-child(4) { animation-delay: -1.6s; }
    .footer-eq i:nth-child(5) { animation-delay: -2.2s; }
}
@keyframes footer-eq { 0%, 100% { transform: scaleY(0.5); } 50% { transform: scaleY(1); } }

/* Back to top - flat, quiet, appears once you've wandered */
.back-to-top { position: fixed; inset-inline-end: 22px; bottom: 22px; z-index: 90;
    width: 46px; height: 46px; border-radius: 50%; cursor: pointer;
    display: grid; place-items: center; color: var(--text-secondary);
    background: var(--bg-elevated); border: 1px solid var(--glass-border-strong);
    opacity: 0; pointer-events: none; transform: translateY(12px);
    transition: opacity 0.3s var(--ease-snap), transform 0.3s var(--ease-snap),
                color 0.2s var(--ease-snap), border-color 0.2s var(--ease-snap); }
.back-to-top .icon { transform: rotate(180deg); }
.back-to-top.show { opacity: 1; pointer-events: auto; transform: translateY(0); }
.back-to-top:hover { color: var(--text-primary); border-color: var(--accent-primary); }
.back-to-top:active { transform: scale(0.92); }
.footer-tagline { color: var(--text-muted); font-size: 0.9rem; margin-top: 0.75rem; max-width: 260px; }
.footer-col h4 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); margin-bottom: 1rem; }
.footer-col a { display: block; color: var(--text-secondary); text-decoration: none; font-size: 0.92rem; padding: 0.3rem 0; transition: color 0.2s; }
.footer-col a:hover { color: var(--accent-primary); }
.footer-bottom { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
    padding-top: var(--sp-5); border-top: 1px solid var(--glass-border); color: var(--text-muted); font-size: 0.88rem; }
.footer-bottom a { color: var(--accent-primary); text-decoration: none; }
.footer-bottom a:hover { text-decoration: underline; }

/* ---- Responsive ---- */
@media (max-width: 860px) {
    .container { padding: 0 var(--sp-4); }
    .nav-links, .nav-cta-wrap { display: none; }
    .nav-toggle { display: inline-flex; }
    .nav { gap: 0.6rem; flex: none; }
    .logo { flex: 0 1 auto; min-width: 0; }  /* keep the wordmark on one line, never squeezed to a wrap */
    .site-header { padding: 0.55rem 0.85rem; gap: 0.5rem; }
    .site-header.mobile-open + .mobile-menu, .mobile-menu.open { display: block; }
    .footer-grid { grid-template-columns: 1fr 1fr; gap: var(--sp-5); }
    .footer-brand { grid-column: 1 / -1; }
}
/* Phones: the language picker collapses to just the globe so the brand and
   menu button always fit on one row. It still opens the same dropdown. */
@media (max-width: 600px) {
    #lang-current-label, .lang-chevron { display: none; }
    .lang-toggle { padding: 0.4rem; }
}
@media (max-width: 380px) {
    .logo-video-wrapper, .logo-video { width: 40px; height: 40px; }
    .logo-text { font-size: 1.3rem; }
}
@media (max-width: 500px) {
    .footer-grid { grid-template-columns: 1fr; }
}

/* Mobile slide-down menu */
.mobile-menu {
    display: none; position: sticky; top: calc(1rem + 64px); z-index: 99; margin: 0.5rem 0;
    padding: var(--sp-4); border-radius: var(--r-md);
    background: rgba(12,12,18,0.9); backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px);
    border: 1px solid var(--glass-border);
}
.mobile-menu.open { display: block; }
.mobile-menu a { display: flex; align-items: center; gap: 0.6rem; color: var(--text-secondary);
    text-decoration: none; padding: 0.7rem 0.5rem; font-weight: 500; border-radius: 8px; }
.mobile-menu a:hover { background: var(--glass-bg); color: var(--text-primary); }
.mobile-menu .mobile-menu-cta { justify-content: center; margin-top: 0.6rem; color: #0a0a0f; }

/* ---- Scroll reveals (shared) ----
   Hidden state is gated on html.js (set by an inline head script) so content
   is never invisible without JavaScript. --reveal-i is set per sibling group
   by JS for an automatic stagger. */
html.js [data-reveal] {
    opacity: 0; transform: translateY(24px);
    transition: opacity 0.75s var(--ease-lofi), transform 0.75s var(--ease-lofi);
    transition-delay: calc(var(--reveal-i, 0) * 90ms);
}
html.js [data-reveal].in-view { opacity: 1; transform: none; }

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
    .bg-gradient { animation: none; }
    .orb { animation: none; }
    html { scroll-behavior: auto; }
    /* Spinners communicate STATE - a frozen partial ring is ambiguous.
       Keep them moving, just slower. */
    .spinner, .screen-spinner {
        animation: spin 1.6s linear infinite !important;
        animation-iteration-count: infinite !important;
    }
}
