/* ==========================================================================
   khudoyberdiyev.uz — dizayn tizimi
   Faqat transform va opacity animatsiya qilinadi (TZ 5.1).
   ========================================================================== */

/* --- Shriftlar ------------------------------------------------------------
   Uchalasida ham U+02BB (ʻ) va U+02BC (ʼ) gliflari cmap'da tasdiqlangan.
   Steklarning oxirida ham glifi bor shrift turadi.                          */

@font-face {
  font-family: "Space Grotesk";
  src: url("/assets/fonts/space-grotesk-latin.woff2") format("woff2");
  font-weight: 600 700;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
                 U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
                 U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Public Sans";
  src: url("/assets/fonts/public-sans-latin.woff2") format("woff2");
  font-weight: 400 600;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
                 U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
                 U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/assets/fonts/ibm-plex-mono-latin.woff2") format("woff2");
  font-weight: 400 500;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
                 U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
                 U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* --- Tokenlar ------------------------------------------------------------ */

:root {
  /* light — kunduzgi uchirilish */
  --bg: #F4F6FF;
  --bg-2: #E8EDFF;
  --surface: #FFFFFF;
  --border: rgba(11, 16, 48, .10);
  --text: #0B1030;
  --muted: #5A6180;
  --accent: #4B32D6;
  /* Tugma foni: oq matn bilan WCAG AA ni taʼminlaydi.
     Havolalar uchun --accent yorqinroq qoladi. */
  --accent-strong: #4B32D6;
  --accent-2: #0E8FA8;
  --star: #FF9F45;
  --danger: #C42B3D;

  --star-ink: #6A74A8;
  --star-opacity: .30;

  --sky-1: #DCE6FF;
  --sky-2: #F4F6FF;

  --font-display: "Space Grotesk", "Public Sans", system-ui, sans-serif;
  --font-body: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", "Public Sans", ui-monospace, monospace;

  --fs-hero: clamp(2.4rem, 9vw, 6rem);
  --fs-h2: clamp(1.7rem, 5vw, 3rem);
  --fs-h3: clamp(1.2rem, 3vw, 1.6rem);
  --fs-body: clamp(1rem, 2.4vw, 1.0625rem);
  --fs-sm: .875rem;
  --fs-mono: .8125rem;

  --measure: 68ch;
  --gutter: clamp(1.25rem, 5vw, 3rem);
  --section-gap: clamp(4rem, 12vh, 9rem);
  --radius: .8rem;

  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #060818;
  --bg-2: #0B0F26;
  --surface: #10142F;
  --border: rgba(255, 255, 255, .08);
  --text: #E8EAF6;
  --muted: #9AA0C0;
  --accent: #7C5CFF;
  --accent-strong: #6A48F5;
  --accent-2: #22D3EE;
  --star: #FFD9A0;
  --danger: #FF6B7A;

  --star-ink: #FFFFFF;
  --star-opacity: .75;

  --sky-1: #0B0F26;
  --sky-2: #060818;

  color-scheme: dark;
}

/* Balandlik oshgani sari osmon quyuqlashadi. IntersectionObserver <body> ga
   data-alt qo'yadi — scroll hodisasi ishlatilmaydi (TZ 5.6). */
body[data-alt="12"]    { --sky-1: #C6D6FF; --sky-2: #E8EDFF; }
body[data-alt="40"]    { --sky-1: #9DB4F0; --sky-2: #D3DEFF; }
body[data-alt="100"]   { --sky-1: #5E6FB8; --sky-2: #A9B8EC; }
body[data-alt="orbit"] { --sky-1: #2B3168; --sky-2: #6A76B4; }

:root[data-theme="dark"] body[data-alt="12"]    { --sky-1: #0D1330; --sky-2: #070A1C; }
:root[data-theme="dark"] body[data-alt="40"]    { --sky-1: #0A0E28; --sky-2: #05071A; }
:root[data-theme="dark"] body[data-alt="100"]   { --sky-1: #070A20; --sky-2: #030512; }
:root[data-theme="dark"] body[data-alt="orbit"] { --sky-1: #04061A; --sky-2: #01020A; }

/* --- Reset --------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.65;
  overflow-x: hidden;
  text-rendering: optimizeLegibility;
}

img, svg, video { max-width: 100%; height: auto; display: block; }
button, input, textarea, select { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.05; letter-spacing: -.02em; margin: 0; }
p { margin: 0 0 1rem; }
a { color: var(--accent); text-underline-offset: .18em; }
a:hover { color: var(--accent-2); }

:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 3px; border-radius: 3px; }

.skip-link {
  position: absolute; left: -9999px; z-index: 100;
  background: var(--surface); color: var(--text);
  padding: .7rem 1.1rem; border-radius: var(--radius); border: 1px solid var(--border);
}
.skip-link:focus { left: 1rem; top: 1rem; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

/* --- Fon: osmon + yulduzlar --------------------------------------------- */

.sky {
  position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background: linear-gradient(180deg, var(--sky-1) 0%, var(--sky-2) 100%);
  transition: background 1.2s ease;
}

.stars {
  position: fixed; left: 0; top: 0; width: 100%; height: 200%;
  z-index: -1; pointer-events: none;
  background-repeat: repeat;
  background-size: 600px 600px;
  opacity: var(--star-opacity);
  will-change: transform;
  animation: drift var(--dur) linear infinite;
}
.stars--far  { --dur: 240s; background-image: url("/assets/img/stars-far.svg");  opacity: calc(var(--star-opacity) * .45); }
.stars--mid  { --dur: 160s; background-image: url("/assets/img/stars-mid.svg");  opacity: calc(var(--star-opacity) * .7); }
.stars--near { --dur:  90s; background-image: url("/assets/img/stars-near.svg"); }

@keyframes drift { to { transform: translate3d(0, -50%, 0); } }

/* Light rejimda yulduzlar deyarli ko'rinmaydi — kunduz. */
:root:not([data-theme="dark"]) .stars { filter: invert(1); }

/* --- Meteoritlar --------------------------------------------------------- */

.meteors { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.meteors i {
  position: absolute; top: -10%; left: var(--x, 50%);
  width: 2px; height: 90px;
  background: linear-gradient(to bottom, transparent, var(--star));
  opacity: 0;
  transform: rotate(28deg);
  animation: meteor 9s var(--delay, 0s) linear infinite;
}
.meteors i:nth-child(1) { --x: 12%; --delay: 0s; }
.meteors i:nth-child(2) { --x: 47%; --delay: 3.4s; }
.meteors i:nth-child(3) { --x: 71%; --delay: 6.1s; }
.meteors i:nth-child(4) { --x: 89%; --delay: 8.2s; }

@keyframes meteor {
  0%   { opacity: 0; transform: translate3d(0, 0, 0) rotate(28deg); }
  4%   { opacity: .9; }
  18%  { opacity: 0; transform: translate3d(-38vw, 78vh, 0) rotate(28deg); }
  100% { opacity: 0; transform: translate3d(-38vw, 78vh, 0) rotate(28deg); }
}

@media (max-width: 768px) {
  .meteors i:nth-child(3), .meteors i:nth-child(4) { display: none; }
}

/* --- Sayyora ------------------------------------------------------------- */

.planet {
  position: fixed; right: -18vmin; bottom: -22vmin;
  width: 62vmin; height: 62vmin; z-index: -1; pointer-events: none;
  opacity: .5;
  will-change: transform;
  animation: spin 300s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Balandlik markerlari ------------------------------------------------ */

.altimeter {
  position: fixed; right: clamp(.5rem, 2vw, 1.5rem); top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  display: grid; gap: .9rem;
  font-family: var(--font-mono); font-size: var(--fs-mono);
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted);
}
.altimeter a { color: inherit; text-decoration: none; opacity: .45; transition: opacity .3s, color .3s; }
.altimeter a:hover { opacity: .9; }
.altimeter a[aria-current="true"] { opacity: 1; color: var(--accent-2); }

@media (max-width: 640px) { .altimeter { display: none; } }

/* --- Layout -------------------------------------------------------------- */

.wrap { width: min(100% - var(--gutter) * 2, 72rem); margin-inline: auto; }

.section {
  padding-block: var(--section-gap);
  scroll-margin-top: 2rem;
}
.section + .section { border-top: 1px solid var(--border); }

/* content-visibility: auto bu yerda ATAYLAB ishlatilmaydi.
   U bo'lim ichki daraxtini "render qilinmagan" holatda ushlaydi, natijada
   scroll-reveal uchun qo'yilgan IntersectionObserver ichkaridagi elementlarni
   ko'rmaydi va bo'lim bo'sh qolib ketishi mumkin. 5 bo'limlik sahifada
   yutuq arzimas, xavf esa real. */
.section--deferred { contain: layout style; }

.section__label {
  font-family: var(--font-mono); font-size: var(--fs-mono);
  letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
  margin: 0 0 .6rem;
}
.section__title { font-size: var(--fs-h2); margin-bottom: 1.5rem; }
.prose { max-width: var(--measure); }
.muted { color: var(--muted); }

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

.hero { padding-block: clamp(4rem, 16vh, 9rem) var(--section-gap); }
.hero__eyebrow {
  font-family: var(--font-mono); font-size: var(--fs-mono);
  letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
  margin: 0 0 .9rem;
}
.hero__title { font-size: var(--fs-hero); font-weight: 700; margin-bottom: 1rem; }
.hero__lead { max-width: 46ch; color: var(--muted); font-size: clamp(1.05rem, 2.6vw, 1.25rem); }

.hero__actions { display: flex; flex-wrap: wrap; gap: .8rem; margin-top: 2rem; }

.status {
  display: inline-flex; align-items: center; gap: .55rem;
  font-family: var(--font-mono); font-size: var(--fs-mono);
  letter-spacing: .06em; color: var(--muted);
  margin-top: 1.8rem;
}
/* Puls halqasi alohida qatlamda: box-shadow animatsiyasi har kadrda
   qayta boʻyashga majbur qilardi (TZ 5.1 taqiqlaydi). Endi faqat
   transform va opacity — butunlay compositor'da. */
.status__dot {
  position: relative;
  width: .6rem; height: .6rem; border-radius: 50%;
  background: var(--dot, #4ade80);
  flex: none;
}
.status__dot::after {
  content: ""; position: absolute; inset: 0;
  border-radius: 50%;
  background: var(--dot, #4ade80);
  will-change: transform, opacity;
  animation: pulse 2.4s ease-out infinite;
}
@keyframes pulse {
  0%   { transform: scale(1);   opacity: .65; }
  70%  { transform: scale(2.8); opacity: 0; }
  100% { transform: scale(2.8); opacity: 0; }
}

.vibe {
  font-family: var(--font-mono); font-size: var(--fs-mono);
  color: var(--muted); opacity: .45; letter-spacing: .1em;
  margin-top: 3rem;
}

/* --- Tugmalar ------------------------------------------------------------ */

.button {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .8rem 1.4rem; border-radius: var(--radius);
  background: var(--accent-strong); color: #fff;
  border: 1px solid transparent; text-decoration: none; font-weight: 600;
  transition: transform .18s ease, opacity .18s ease;
}
.button:hover { color: #fff; opacity: .92; transform: translateY(-1px); }
.button:active { transform: translateY(0); }
.button--ghost { background: transparent; color: var(--text); border-color: var(--border); }
.button--ghost:hover { color: var(--text); border-color: var(--accent); }

/* --- Teglar -------------------------------------------------------------- */

.tag-list { display: flex; flex-wrap: wrap; gap: .5rem; list-style: none; padding: 0; margin: 1rem 0; }
.tag {
  font-family: var(--font-mono); font-size: var(--fs-mono);
  letter-spacing: .06em;
  padding: .3rem .6rem; border-radius: .4rem;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
}

/* --- Loyiha kartalari ---------------------------------------------------- */

.projects__grid {
  list-style: none; padding: 0; margin: 0;
  display: grid; gap: 1.25rem;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr));
}

.project-card {
  position: relative;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.3rem;
  display: grid; gap: .6rem; align-content: start;
  transition: transform .22s ease, border-color .22s ease;
}
.project-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.project-card h3 { font-size: var(--fs-h3); }
.project-card h3 a { color: inherit; text-decoration: none; }
/* Butun karta bosiladigan bo'lsin, lekin sarlavha havolasi haqiqiy <a> qolsin. */
.project-card h3 a::after { content: ""; position: absolute; inset: 0; }
.project-card p { margin: 0; color: var(--muted); font-size: var(--fs-sm); }

.project-card--offline { opacity: .55; filter: grayscale(.7); }

.status-badge {
  display: inline-flex; align-items: center; gap: .4rem;
  font-family: var(--font-mono); font-size: var(--fs-mono);
  letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}
.status-badge::before {
  content: ""; width: .5rem; height: .5rem; border-radius: 50%;
  background: var(--badge, var(--muted));
}
.status-badge--orbit       { --badge: #4ade80; }
.status-badge--completed   { --badge: var(--accent-2); }
.status-badge--maintenance { --badge: #fbbf24; }
.status-badge--offline     { --badge: var(--muted); }
.status-badge--secret      { --badge: var(--danger); }

.redacted {
  background: currentColor; color: var(--muted);
  border-radius: .2rem; user-select: none;
}

/* --- Loyiha sahifasi ----------------------------------------------------- */

.project { padding-block: var(--section-gap); }
.project__back { font-family: var(--font-mono); font-size: var(--fs-mono); }
.project__header { margin-bottom: 1.5rem; }
.project__header h1 { font-size: var(--fs-h2); margin-bottom: .6rem; }
.project__lead { max-width: var(--measure); color: var(--muted); font-size: 1.1rem; }
.project__body { max-width: var(--measure); }
.project__body :is(h2, h3) { margin-top: 2rem; margin-bottom: .6rem; }
.project__gallery {
  list-style: none; padding: 0; display: grid; gap: 1rem; margin: 2rem 0;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr));
}
/* Rasm yuklanmasdan oldin ham joy band qilinadi — aks holda u kelganda
   sahifa siljiydi (CLS). Galereya rasmlarining oʻlchami oldindan
   nomaʼlum, shuning uchun aspect-ratio bilan zaxira qilamiz. */
.project__gallery img {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: var(--surface);
}
.project__cta { margin-top: 2rem; }

/* --- Forma --------------------------------------------------------------- */

.form { display: grid; gap: 1rem; max-width: 34rem; }
.form label { font-size: var(--fs-sm); font-weight: 600; display: grid; gap: .35rem; }
.form input, .form textarea {
  padding: .7rem .85rem; border-radius: .5rem;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-weight: 400;
}
.form textarea { min-height: 8rem; resize: vertical; }
.form__honey {
  position: absolute; left: -9999px; width: 1px; height: 1px;
  opacity: 0; pointer-events: none;
}
.alert { padding: .8rem 1rem; border-radius: .5rem; font-size: var(--fs-sm); }
.alert--ok { background: color-mix(in srgb, #4ade80 14%, transparent); border: 1px solid #4ade80; }
.alert--error { background: color-mix(in srgb, var(--danger) 14%, transparent); border: 1px solid var(--danger); }

.links { display: flex; flex-wrap: wrap; gap: .7rem; list-style: none; padding: 0; margin: 2rem 0 0; }
.links a {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .55rem .9rem; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface);
  text-decoration: none; color: var(--text); font-size: var(--fs-sm);
}
.links a:hover { border-color: var(--accent); color: var(--text); }

/* --- Tema tugmasi -------------------------------------------------------- */

.theme-toggle {
  position: fixed; top: 1rem; right: 1rem; z-index: 10;
  width: 2.5rem; height: 2.5rem; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--muted); cursor: pointer;
  transition: color .2s, border-color .2s;
}
.theme-toggle:hover { color: var(--text); border-color: var(--accent); }

/* --- Footer -------------------------------------------------------------- */

.site-footer {
  border-top: 1px solid var(--border);
  padding-block: 2.5rem;
  color: var(--muted); font-size: var(--fs-sm);
}

/* --- Scroll-reveal ------------------------------------------------------- */

/* Yashirish faqat JS ishlayotganda qo'llanadi: skript yuklanmasa yoki
   xato bersa, mazmun ko'rinib turaveradi. */
.js .reveal {
  opacity: 0;
  transform: translate3d(0, 16px, 0);
  transition: opacity .5s ease, transform .5s ease;
}
.js .reveal.is-in { opacity: 1; transform: none; }
.js .reveal:nth-child(2) { transition-delay: .06s; }
.js .reveal:nth-child(3) { transition-delay: .12s; }
.js .reveal:nth-child(4) { transition-delay: .18s; }
.js .reveal:nth-child(5) { transition-delay: .24s; }

/* --- Xato sahifalari ----------------------------------------------------- */

.error-page { display: grid; place-items: center; min-height: 100dvh; text-align: center; }
.error-page h1 { font-size: clamp(3rem, 14vw, 7rem); }

/* --- Yengil rejim -------------------------------------------------------- */

/* Zaif qurilma yoki sekin tarmoq: bitta statik yulduz qatlami qoladi. */
.lite .stars { animation: none; }
.lite .stars--mid, .lite .stars--near { display: none; }
.lite .meteors, .lite .planet { display: none; }
.lite .reveal { transition: opacity .2s ease; transform: none; }
.js .reveal.is-in { opacity: 1; }

/* Tab ko'rinmayotganda GPU ni bo'sh qo'yamiz. */
.paused *, .paused *::before, .paused *::after { animation-play-state: paused !important; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation: none !important;
    transition-duration: .01ms !important;
  }
  .js .reveal { opacity: 1; transform: none; }
}

/* --- Kosmonavt (TZ 6.2) -------------------------------------------------- */

.cosmonaut { width: min(100%, 15rem); height: auto; }
.cosmonaut__body {
  transform-origin: 50% 100%;
  animation: breathe 6s ease-in-out infinite alternate;
  will-change: transform;
}
@keyframes breathe { to { transform: translateY(-6px); } }

.cosmonaut__code {
  animation: codeflow 18s linear infinite;
  will-change: transform;
}
@keyframes codeflow { to { transform: translateY(-80px); } }

.lite .cosmonaut__body, .lite .cosmonaut__code { animation: none; }

.hero__grid {
  display: grid; gap: clamp(1.5rem, 5vw, 3rem); align-items: center;
  grid-template-columns: 1fr;
}
@media (min-width: 62rem) {
  .hero__grid { grid-template-columns: 1.25fr .75fr; }
}

/* --- Stack --------------------------------------------------------------- */

.stack-list { display: flex; flex-wrap: wrap; gap: .6rem; list-style: none; padding: 0; margin: 0; }
.stack-list li {
  font-family: var(--font-mono); font-size: var(--fs-sm);
  padding: .45rem .85rem; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
}

/* --- Xizmatlar ----------------------------------------------------------- */

.services { list-style: none; padding: 0; margin: 0; display: grid; gap: 1rem;
            grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); }
.services li {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.2rem;
  display: flex; gap: .8rem; align-items: flex-start;
}
.services li::before {
  content: "→"; color: var(--accent-2); font-family: var(--font-mono); flex: none;
}

/* --- Loyiha paneli (TZ 6.3) ---------------------------------------------- */
/* Modal emas — to'liq sahifa his qilinadi. URL pushState bilan o'zgaradi. */

.panel {
  position: fixed; inset: 0; z-index: 50;
  background: var(--bg);
  overflow-y: auto; overscroll-behavior: contain;
  opacity: 0;
  transform: translate3d(0, 12px, 0);
  transition: opacity .28s ease, transform .28s ease;
}
.panel[hidden] { display: none; }
.panel.is-open { opacity: 1; transform: none; }

.panel__close {
  position: sticky; top: 0; margin-left: auto;
  display: flex; align-items: center; gap: .45rem;
  padding: .7rem 1rem; border: 0; border-radius: 0 0 0 var(--radius);
  background: var(--surface); color: var(--muted);
  font-family: var(--font-mono); font-size: var(--fs-mono);
  letter-spacing: .06em; text-transform: uppercase; cursor: pointer;
}
.panel__close:hover { color: var(--text); }

.panel__body { padding-bottom: 4rem; }

.panel__loading {
  padding: 4rem var(--gutter); color: var(--muted);
  font-family: var(--font-mono); font-size: var(--fs-mono);
}

/* Panel ochiq bo'lganda orqa fon siljimasin. */
body.panel-open { overflow: hidden; }

.lite .panel { transition: opacity .15s ease; transform: none; }
