/*
 * Komponent stillari. Tailwind v4 bilan bir xil kaskad tartibida ishlashi uchun
 * qatlamlar tartibi oldindan e'lon qilinadi — utility klasslar doimo ustun turadi.
 */
@layer theme, base, components, utilities;

@layer base {
  :root {
    color-scheme: dark;
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  }
  html { -webkit-tap-highlight-color: transparent; }
  :focus-visible {
    outline: 2px solid var(--color-gold-400, #e8b94f);
    outline-offset: 3px;
    border-radius: 10px;
  }
}

@layer components {
  /* ───────── Matn gradienti ───────── */
  .text-gradient {
    background: linear-gradient(100deg, #f8e6b5 0%, #e8b94f 45%, #d49b25 70%, #f2d283 100%);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: shine 6s linear infinite;
  }

  /* ───────── Hero bezaklari ───────── */
  .hero-glow {
    background: radial-gradient(circle, rgb(232 185 79 / 0.18), transparent 65%);
    filter: blur(20px);
  }
  .grain {
    opacity: 0.08;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  }
  .grid-lines {
    background-image:
      linear-gradient(to right, rgb(255 255 255 / 0.035) 1px, transparent 1px),
      linear-gradient(to bottom, rgb(255 255 255 / 0.035) 1px, transparent 1px);
    background-size: 72px 72px;
    mask-image: radial-gradient(ellipse 70% 60% at 30% 50%, #000 30%, transparent 75%);
  }
  [data-parallax] { will-change: transform; transition: transform 0.1s linear; }

  .feature-chip {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding: 1rem;
    border-radius: 1.1rem;
    border: 1px solid rgb(255 255 255 / 0.08);
    background: rgb(255 255 255 / 0.03);
    backdrop-filter: blur(10px);
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
    transition: border-color 0.3s, transform 0.3s var(--ease-out);
  }
  .feature-chip:hover { border-color: rgb(232 185 79 / 0.35); transform: translateY(-3px); }

  .glass-card {
    border-radius: 1.75rem;
    border: 1px solid rgb(255 255 255 / 0.1);
    background: linear-gradient(145deg, rgb(255 255 255 / 0.09), rgb(255 255 255 / 0.02));
    backdrop-filter: blur(20px) saturate(140%);
    box-shadow: 0 30px 80px -20px rgb(0 0 0 / 0.6), inset 0 1px 0 rgb(255 255 255 / 0.08);
  }
  .route-row {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    border: 1px solid rgb(255 255 255 / 0.07);
    background: rgb(11 15 24 / 0.65);
    backdrop-filter: blur(12px);
    font-size: 0.9rem;
  }
  .route-icon {
    display: grid;
    place-items: center;
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 0.7rem;
    color: #07090f;
  }

  .scroll-mouse {
    position: relative;
    width: 24px;
    height: 38px;
    border: 2px solid currentColor;
    border-radius: 999px;
  }
  .scroll-mouse::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 7px;
    width: 3px;
    height: 7px;
    margin-left: -1.5px;
    border-radius: 2px;
    background: currentColor;
    animation: scroll-dot 1.8s var(--ease-out) infinite;
  }

  /* ───────── Tugmalar ───────── */
  .btn-primary {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.95rem 1.75rem;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.95rem;
    color: #07090f;
    background: linear-gradient(135deg, #f8e6b5, #e8b94f 45%, #d49b25);
    box-shadow: 0 10px 30px -8px rgb(212 155 37 / 0.55), inset 0 1px 0 rgb(255 255 255 / 0.5);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s var(--ease-out), box-shadow 0.3s var(--ease-out), opacity 0.2s;
  }
  .btn-primary::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(110deg, transparent 30%, rgb(255 255 255 / 0.55) 50%, transparent 70%);
    transform: translateX(-120%);
    transition: transform 0.8s var(--ease-out);
  }
  .btn-primary:hover { transform: translateY(-2px); box-shadow: 0 18px 40px -10px rgb(212 155 37 / 0.7), inset 0 1px 0 rgb(255 255 255 / 0.5); }
  .btn-primary:hover::before { transform: translateX(120%); }
  .btn-primary:active { transform: translateY(0) scale(0.98); }
  .btn-primary:disabled { opacity: 0.7; cursor: progress; transform: none; }

  /* ───────── Bosqichlar ───────── */
  .step-card {
    display: flex;
    gap: 1.1rem;
    padding: 1.1rem 1.25rem;
    border-radius: 1.25rem;
    border: 1px solid rgb(255 255 255 / 0.06);
    background: rgb(255 255 255 / 0.02);
    transition: border-color 0.3s, background 0.3s;
  }
  .step-card:hover { border-color: rgb(232 185 79 / 0.25); background: rgb(232 185 79 / 0.04); }
  .step-num {
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--color-gold-400);
    padding-top: 0.15rem;
  }

  /* ───────── Forma ───────── */
  .form-shell {
    position: relative;
    border-radius: 2rem;
    background: linear-gradient(160deg, rgb(28 36 52 / 0.85), rgb(11 15 24 / 0.95));
    border: 1px solid rgb(255 255 255 / 0.08);
    box-shadow: 0 40px 100px -30px rgb(0 0 0 / 0.8);
  }
  .form-shell::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    padding: 1px;
    background: conic-gradient(from var(--angle, 0deg), transparent 0 70%, rgb(232 185 79 / 0.7) 85%, transparent 100%);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    animation: spin-border 8s linear infinite;
    pointer-events: none;
  }

  .field-label {
    display: inline-flex;
    align-items: center;
    font-size: 0.875rem;
    font-weight: 600;
    color: rgb(226 232 240);
  }
  .field-error {
    min-height: 0;
    margin-top: 0.5rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: rgb(253 164 175);
  }
  .field-error:empty { display: none; }

  .input-wrap { position: relative; }
  .input-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    translate: 0 -50%;
    color: rgb(100 116 139);
    pointer-events: none;
    transition: color 0.2s;
  }
  .input-wrap:focus-within .input-icon { color: var(--color-gold-300); }
  .input {
    width: 100%;
    padding: 0.95rem 1.1rem;
    border-radius: 1rem;
    border: 1px solid rgb(255 255 255 / 0.1);
    background: rgb(7 9 15 / 0.6);
    color: #fff;
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s, opacity 0.2s;
  }
  .input::placeholder { color: rgb(100 116 139); }
  .input:hover { border-color: rgb(255 255 255 / 0.18); }
  .input:focus {
    outline: none;
    border-color: rgb(232 185 79 / 0.6);
    background: rgb(7 9 15 / 0.85);
    box-shadow: 0 0 0 4px rgb(232 185 79 / 0.12);
  }
  .input:disabled { opacity: 0.45; cursor: not-allowed; }
  [data-invalid] .input,
  [data-invalid] .recipient-card { border-color: rgb(251 113 133 / 0.55); }
  [data-invalid] .input:focus { box-shadow: 0 0 0 4px rgb(251 113 133 / 0.12); }
  .shake { animation: shake 0.4s var(--ease-out); }

  /* Segment (murojaat turi) */
  .segment { position: relative; cursor: pointer; }
  .segment span {
    display: block;
    padding: 0.7rem 0.5rem;
    border-radius: 0.75rem;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: rgb(148 163 184);
    transition: all 0.25s var(--ease-out);
  }
  .segment:hover span { color: #fff; }
  .segment input:checked + span {
    color: #07090f;
    background: linear-gradient(135deg, #f8e6b5, #e8b94f);
    box-shadow: 0 6px 18px -6px rgb(232 185 79 / 0.6);
  }
  .segment input:focus-visible + span { outline: 2px solid var(--color-gold-400); outline-offset: 2px; }

  /* Qabul qiluvchi kartalari */
  .recipient-card {
    --accent: 232 185 79;
    position: relative;
    display: block;
    padding: 1.15rem;
    border-radius: 1.25rem;
    border: 1px solid rgb(255 255 255 / 0.08);
    background: rgb(7 9 15 / 0.5);
    cursor: pointer;
    overflow: hidden;
    transition: border-color 0.3s, transform 0.3s var(--ease-out), background 0.3s, box-shadow 0.3s;
  }
  .recipient-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(240px circle at var(--mx, 50%) var(--my, 0%), rgb(var(--accent) / 0.14), transparent 60%);
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
  }
  .recipient-card:hover { transform: translateY(-3px); border-color: rgb(var(--accent) / 0.35); }
  .recipient-card:hover::after { opacity: 1; }
  .recipient-card:has(input:checked) {
    border-color: rgb(var(--accent) / 0.8);
    background: rgb(var(--accent) / 0.07);
    box-shadow: 0 0 0 1px rgb(var(--accent) / 0.4), 0 18px 40px -16px rgb(var(--accent) / 0.45);
  }
  .recipient-card:has(input:checked)::after { opacity: 1; }
  .recipient-card:has(input:focus-visible) { outline: 2px solid rgb(var(--accent)); outline-offset: 3px; }
  .recipient-icon {
    display: grid;
    place-items: center;
    width: 2.6rem;
    height: 2.6rem;
    border-radius: 0.85rem;
    color: rgb(var(--accent));
    background: rgb(var(--accent) / 0.12);
    transition: transform 0.4s var(--ease-out), background 0.3s, color 0.3s;
  }
  .recipient-card:has(input:checked) .recipient-icon {
    color: #07090f;
    background: rgb(var(--accent));
    transform: rotate(-8deg) scale(1.05);
  }
  .recipient-check {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: grid;
    place-items: center;
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 999px;
    border: 1.5px solid rgb(255 255 255 / 0.15);
    color: transparent;
    transition: all 0.3s var(--ease-out);
  }
  .recipient-card:has(input:checked) .recipient-check {
    border-color: rgb(var(--accent));
    background: rgb(var(--accent));
    color: #07090f;
    transform: scale(1.1);
  }

  /* Anonim toggle */
  .toggle {
    position: relative;
    width: 2.5rem;
    height: 1.4rem;
    border-radius: 999px;
    background: rgb(255 255 255 / 0.1);
    transition: background 0.25s;
  }
  .toggle::after {
    content: '';
    position: absolute;
    top: 0.2rem;
    left: 0.2rem;
    width: 1rem;
    height: 1rem;
    border-radius: 999px;
    background: #fff;
    transition: transform 0.3s var(--ease-out);
  }
  .peer:checked + .toggle { background: var(--color-gold-400); }
  .peer:checked + .toggle::after { transform: translateX(1.1rem); background: #07090f; }
  .peer:focus-visible + .toggle { outline: 2px solid var(--color-gold-400); outline-offset: 3px; }

  .spinner {
    width: 1.15rem;
    height: 1.15rem;
    border-radius: 999px;
    border: 2.5px solid rgb(7 9 15 / 0.25);
    border-top-color: #07090f;
    animation: spin 0.7s linear infinite;
  }

  /* ───────── Dialog ───────── */
  .success-dialog {
    width: min(26rem, calc(100% - 2rem));
    margin: auto;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
  }
  .success-dialog::backdrop { background: rgb(7 9 15 / 0.75); backdrop-filter: blur(8px); }
  .success-dialog[open] { animation: pop-in 0.5s var(--ease-out); }
  .success-dialog[open]::backdrop { animation: fade-in 0.3s ease; }
  .check-draw use { stroke-dasharray: 30; stroke-dashoffset: 30; animation: draw 0.6s 0.25s var(--ease-out) forwards; }

  /* ───────── Toast ───────── */
  .toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    max-width: 28rem;
    padding: 0.85rem 1.15rem;
    border-radius: 1rem;
    border: 1px solid rgb(255 255 255 / 0.1);
    background: rgb(18 24 38 / 0.92);
    backdrop-filter: blur(14px);
    font-size: 0.875rem;
    color: #fff;
    box-shadow: 0 20px 50px -15px rgb(0 0 0 / 0.7);
    animation: toast-in 0.45s var(--ease-out);
  }
  .toast[data-variant='error'] { border-color: rgb(251 113 133 / 0.4); }
  .toast[data-variant='error'] svg { color: rgb(253 164 175); }
  .toast[data-variant='success'] svg { color: rgb(110 231 183); }
  .toast.is-leaving { animation: toast-out 0.3s ease forwards; }

  /* ───────── Scroll reveal ───────── */
  .reveal {
    opacity: 0;
    transform: translateY(24px);
    filter: blur(6px);
    transition: opacity 0.9s var(--ease-out), transform 0.9s var(--ease-out), filter 0.9s var(--ease-out);
    transition-delay: var(--d, 0ms);
  }
  .reveal.is-visible { opacity: 1; transform: none; filter: none; }

  [data-header].is-scrolled {
    background: rgb(7 9 15 / 0.72);
    backdrop-filter: blur(16px) saturate(150%);
    box-shadow: 0 1px 0 rgb(255 255 255 / 0.06);
  }
}

@property --angle { syntax: '<angle>'; inherits: false; initial-value: 0deg; }

@keyframes shine { to { background-position: 200% center; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes spin-border { to { --angle: 360deg; } }
@keyframes scroll-dot { 0% { opacity: 0; transform: translateY(0); } 40% { opacity: 1; } 100% { opacity: 0; transform: translateY(12px); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@keyframes pop-in { from { opacity: 0; transform: translateY(20px) scale(0.94); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(0.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(10px) scale(0.96); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .reveal { opacity: 1; transform: none; filter: none; }
}
