:root {
  --bg: #09111f;
  --surface: #111c2f;
  --surface-soft: #16233a;
  --text: #f6f8fc;
  --muted: #aab4c5;
  --primary: #6f7cff;
  --primary-hover: #8993ff;
  --border: rgba(255, 255, 255, 0.09);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  --radius: 24px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: "Vazirmatn", Tahoma, sans-serif;
  background:
    radial-gradient(circle at top right, rgba(111, 124, 255, 0.16), transparent 30%),
    var(--bg);
  color: var(--text);
  line-height: 1.9;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.container {
  width: min(1120px, calc(100% - 40px));
  margin-inline: auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(9, 17, 31, 0.78);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(18px);
}

.nav {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  font-size: 1.1rem;
  font-weight: 800;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 28px;
}

.nav-links a {
  color: var(--muted);
  font-size: 0.95rem;
  transition: 0.2s ease;
}

.nav-links a:hover {
  color: var(--text);
}

.menu-toggle {
  display: none;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.menu-toggle span {
  display: block;
  width: 25px;
  height: 2px;
  margin: 5px 0;
  background: var(--text);
}

.hero {
  min-height: calc(100vh - 74px);
  display: grid;
  align-items: center;
  padding: 90px 0;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.35fr 0.65fr;
  align-items: center;
  gap: 70px;
}

.eyebrow,
.section-label {
  color: var(--primary-hover);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.hero h1 {
  max-width: 760px;
  margin: 14px 0 24px;
  font-size: clamp(2.6rem, 7vw, 5.4rem);
  line-height: 1.15;
  letter-spacing: -0.04em;
}

.hero h1 span {
  color: var(--primary-hover);
}

.hero-text {
  max-width: 690px;
  color: var(--muted);
  font-size: 1.08rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 34px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 24px;
  border-radius: 14px;
  font-weight: 700;
  transition: 0.2s ease;
}

.button.primary {
  background: var(--primary);
  color: white;
}

.button.primary:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
}

.button.secondary {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
}

.button.secondary:hover {
  background: rgba(255, 255, 255, 0.08);
}

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 34px;
  margin-top: 46px;
}

.hero-stats div {
  display: grid;
  gap: 2px;
}

.hero-stats strong {
  font-size: 1.15rem;
}

.hero-stats span {
  color: var(--muted);
  font-size: 0.84rem;
}

.hero-card {
  position: relative;
  overflow: hidden;
  min-height: 420px;
  padding: 38px;
  border: 1px solid var(--border);
  border-radius: 34px;
  background:
    linear-gradient(145deg, rgba(111, 124, 255, 0.26), transparent 48%),
    var(--surface);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.hero-card::before {
  content: "";
  position: absolute;
  width: 230px;
  height: 230px;
  top: -60px;
  left: -60px;
  border-radius: 50%;
  background: rgba(111, 124, 255, 0.14);
  filter: blur(8px);
}

.avatar {
  width: 112px;
  height: 112px;
  margin-bottom: 26px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 30px;
  background: rgba(255,255,255,.07);
  font-size: 2rem;
  font-weight: 800;
}

.hero-card h2 {
  font-size: 1.65rem;
}

.hero-card p {
  color: var(--muted);
}

.status {
  width: fit-content;
  margin-top: 22px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(66, 211, 146, 0.12);
  color: #7ee8b5;
  font-size: 0.85rem;
  font-weight: 700;
}

.section {
  padding: 110px 0;
}

.section-grid {
  display: grid;
  grid-template-columns: 0.45fr 1fr;
  gap: 70px;
}

.section-title {
  margin-top: 8px;
  font-size: clamp(2rem, 5vw, 3.4rem);
  line-height: 1.25;
}

.about-card,
.contact-card {
  padding: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.035);
}

.about-card p,
.section-heading > p,
.contact-card p {
  color: var(--muted);
}

.skills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

.skills span {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-soft);
  color: #dbe1ed;
  font-size: 0.88rem;
}

.portfolio-section {
  background: rgba(255, 255, 255, 0.018);
  border-block: 1px solid var(--border);
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 30px;
  margin-bottom: 42px;
}

.section-heading > p {
  max-width: 480px;
}

.portfolio-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.project-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: 0.25s ease;
}

.project-card:hover {
  transform: translateY(-7px);
  border-color: rgba(111, 124, 255, 0.45);
}

.project-image {
  aspect-ratio: 16 / 10;
  display: grid;
  place-items: center;
  background:
    linear-gradient(135deg, rgba(111,124,255,.32), rgba(255,255,255,.04)),
    var(--surface-soft);
}

.project-image span {
  font-size: 1.2rem;
  font-weight: 800;
}

.project-content {
  padding: 24px;
}

.project-category {
  color: var(--primary-hover);
  font-size: 0.82rem;
  font-weight: 700;
}

.project-content h3 {
  margin: 7px 0 9px;
  font-size: 1.25rem;
}

.project-content p {
  color: var(--muted);
  font-size: 0.92rem;
}

.contact-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 40px;
  background:
    linear-gradient(120deg, rgba(111, 124, 255, 0.18), transparent 45%),
    var(--surface);
}

.contact-card p {
  max-width: 680px;
  margin-top: 16px;
}

.site-footer {
  padding: 26px 0;
  border-top: 1px solid var(--border);
}

.footer-content {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  color: var(--muted);
  font-size: 0.9rem;
}

.footer-content a:hover {
  color: var(--text);
}

@media (max-width: 900px) {
  .hero-grid,
  .section-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    padding: 70px 0;
  }

  .hero-card {
    min-height: 340px;
  }

  .portfolio-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .section-heading,
  .contact-card {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 680px) {
  .container {
    width: min(100% - 28px, 1120px);
  }

  .menu-toggle {
    display: block;
  }

  .nav-links {
    position: absolute;
    top: 74px;
    right: 14px;
    left: 14px;
    display: none;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: rgba(17, 28, 47, 0.98);
    box-shadow: var(--shadow);
  }

  .nav-links.open {
    display: grid;
  }

  .hero h1 {
    font-size: 2.65rem;
  }

  .hero-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 22px;
  }

  .section {
    padding: 78px 0;
  }

  .portfolio-grid {
    grid-template-columns: 1fr;
  }

  .about-card,
  .contact-card {
    padding: 26px;
  }

  .footer-content {
    flex-direction: column;
    text-align: center;
  }
}

/* Global three-mode theme system */
html[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f8fc;
  --surface: #ffffff;
  --surface-soft: #eef2f8;
  --text: #14213d;
  --muted: #607089;
  --primary: #4f5ee8;
  --primary-hover: #3646d3;
  --border: rgba(20, 33, 61, 0.12);
  --shadow: 0 24px 60px rgba(30, 41, 59, 0.12);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #09111f;
  --surface: #111c2f;
  --surface-soft: #16233a;
  --text: #f6f8fc;
  --muted: #aab4c5;
  --primary: #6f7cff;
  --primary-hover: #8993ff;
  --border: rgba(255, 255, 255, 0.09);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}

html[data-theme="light"] body {
  background:
    radial-gradient(circle at top right, rgba(79, 94, 232, 0.10), transparent 30%),
    var(--bg);
}

html[data-theme="light"] .site-header {
  background: rgba(246, 248, 252, 0.84);
}

html[data-theme="dark"] .site-header {
  background: rgba(9, 17, 31, 0.78);
}

html[data-theme="light"] .button.secondary,
html[data-theme="light"] .calculator-result,
html[data-theme="light"] .calculator-section {
  background: rgba(20, 33, 61, 0.035);
}

html[data-theme="light"] .trust-points,
html[data-theme="light"] .profit-calculator label {
  color: var(--text);
}

html[data-theme="light"] .service-badge,
html[data-theme="light"] .calculator-result .recommended strong {
  color: #087443;
}

.theme-picker {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-soft);
  color: var(--text);
  white-space: nowrap;
}

.theme-picker-icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  color: var(--primary-hover);
  font-size: 1.05rem;
}

.theme-picker select {
  max-width: 92px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}

.theme-picker option {
  background: var(--surface);
  color: var(--text);
}

.auth-site-header { position: sticky; }
.auth-nav { min-height: 66px; }
.auth-shell { min-height: calc(100vh - 66px); }

@media (max-width: 760px) {
  .nav { gap: 10px; }
  .theme-picker { margin-inline-start: auto; }
  .theme-picker select { max-width: 76px; font-size: 0.78rem; }
}

/* Shared dual-theme interaction system */
html { background: var(--bg); }
body {
  transition: background-color .28s ease, color .28s ease;
}
/* Content stays visible by default. Motion is progressively enhanced only when JS loads. */
body::before { display: none; }

.ui-reveal {
  opacity: 1;
  transform: none;
}
html.motion-enabled .ui-reveal {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity .62s ease var(--reveal-delay, 0ms), transform .62s cubic-bezier(.2,.8,.2,1) var(--reveal-delay, 0ms);
}
html.motion-enabled .ui-reveal.is-visible { opacity: 1; transform: none; }
.ui-control { position: relative; transition: transform .18s ease, box-shadow .18s ease, background-color .2s ease, border-color .2s ease, color .2s ease; }
.ui-control:hover:not(:disabled) { transform: translateY(-2px); }
.ui-control:active:not(:disabled) { transform: translateY(0) scale(.98); }
.ui-control:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 28%, transparent);
  outline-offset: 3px;
}

/* Improved theme control */
.theme-picker {
  position: relative;
  min-width: 126px;
  padding: 5px 8px 5px 5px;
  border-color: color-mix(in srgb, var(--border) 84%, var(--primary) 16%);
  background: color-mix(in srgb, var(--surface) 92%, var(--primary) 8%);
  box-shadow: 0 8px 24px color-mix(in srgb, var(--text) 8%, transparent);
  transition: background-color .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.theme-picker:hover { border-color: color-mix(in srgb, var(--primary) 46%, var(--border)); }
.theme-picker-icon {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--primary) 13%, transparent);
  color: var(--primary);
  font-size: 1rem;
}
.theme-picker select {
  width: 82px;
  max-width: none;
  appearance: none;
  padding-inline: 4px 18px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: left 8px center, left 4px center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

/* Stronger accessible light palette */
html[data-theme="light"] {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #edf2f8;
  --text: #111827;
  --muted: #4b5f78;
  --primary: #3f51d7;
  --primary-hover: #2d3db5;
  --border: rgba(17, 24, 39, .15);
  --shadow: 0 20px 55px rgba(15, 23, 42, .12);
}
html[data-theme="light"] ::placeholder { color: #718198; opacity: 1; }
html[data-theme="light"] .nav-links a,
html[data-theme="light"] .hero-text,
html[data-theme="light"] .hero-card p,
html[data-theme="light"] .project-content p,
html[data-theme="light"] .site-footer,
html[data-theme="light"] .auth-info p,
html[data-theme="light"] .auth-info li,
html[data-theme="light"] .field-help,
html[data-theme="light"] .auth-warning { color: var(--muted); }
html[data-theme="light"] .button.secondary,
html[data-theme="light"] .about-card,
html[data-theme="light"] .contact-card,
html[data-theme="light"] .project-card {
  background: rgba(255,255,255,.78);
  border-color: var(--border);
}
html[data-theme="light"] .button.secondary:hover { background: #e7ecf5; }
html[data-theme="light"] .avatar { background: #eef2ff; border-color: #cfd7f5; color: #2637a5; }
html[data-theme="light"] .status { color: #087443; background: #def7ec; }
html[data-theme="light"] input,
html[data-theme="light"] select,
html[data-theme="light"] textarea { caret-color: var(--primary); }

@media (max-width: 760px) {
  .theme-picker { min-width: 108px; }
  .theme-picker select { width: 66px; font-size: .78rem; }
}
@media (prefers-reduced-motion: reduce) {
  body, .ui-reveal, .ui-control { transition: none !important; }
  .ui-reveal { opacity: 1; transform: none; }
}


/* Custom theme dropdown redesign */
.theme-native-select {
  position: absolute !important;
  inset: 0 auto auto 0 !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.theme-picker {
  position: relative;
  min-width: 144px;
  gap: 8px;
  padding: 6px;
  border-radius: 16px;
  overflow: visible;
}

.theme-dropdown-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 92px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 800;
  padding: 8px 10px;
  border-radius: 12px;
  cursor: pointer;
}

.theme-picker.is-open .theme-dropdown-toggle {
  background: color-mix(in srgb, var(--primary) 10%, transparent);
}

.theme-dropdown-value {
  line-height: 1;
}

.theme-dropdown-chevron {
  font-size: 0.9rem;
  opacity: 0.8;
  transition: transform .2s ease, opacity .2s ease;
}

.theme-picker.is-open .theme-dropdown-chevron {
  transform: rotate(180deg);
  opacity: 1;
}

.theme-dropdown-menu {
  position: absolute;
  inset-inline-start: 0;
  inset-inline-end: 0;
  top: calc(100% + 10px);
  z-index: 60;
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: color-mix(in srgb, var(--surface) 95%, var(--primary) 5%);
  box-shadow: 0 22px 50px color-mix(in srgb, var(--text) 16%, transparent);
  backdrop-filter: blur(16px);
  opacity: 0;
  transform: translateY(8px) scale(.98);
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}

.theme-picker.is-open .theme-dropdown-menu {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.theme-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  color: var(--text);
  text-align: right;
  font: inherit;
  cursor: pointer;
  transition: background-color .18s ease, border-color .18s ease, transform .18s ease;
}

.theme-option:hover,
.theme-option:focus-visible {
  background: color-mix(in srgb, var(--primary) 9%, var(--surface));
  border-color: color-mix(in srgb, var(--primary) 25%, var(--border));
  outline: none;
}

.theme-option:active { transform: scale(.985); }

.theme-option-main {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.theme-option-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--primary) 14%, transparent);
  color: var(--primary);
  font-size: 1rem;
  flex-shrink: 0;
}

.theme-option-copy {
  display: grid;
  gap: 2px;
}

.theme-option-copy strong {
  font-size: 0.98rem;
  line-height: 1.2;
}

.theme-option-copy small {
  color: var(--muted);
  font-size: 0.77rem;
}

.theme-option-check {
  opacity: 0;
  color: var(--primary);
  font-weight: 900;
  font-size: 0.95rem;
  transform: scale(.9);
  transition: opacity .18s ease, transform .18s ease;
}

.theme-option.is-active {
  background: color-mix(in srgb, var(--primary) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--primary) 30%, var(--border));
}

.theme-option.is-active .theme-option-check {
  opacity: 1;
  transform: scale(1);
}

html[data-theme="light"] .theme-dropdown-menu {
  background: rgba(255,255,255,.96);
  border-color: rgba(17,24,39,.12);
  box-shadow: 0 22px 44px rgba(15,23,42,.14);
}

html[data-theme="dark"] .theme-dropdown-menu {
  background: rgba(17,24,39,.96);
  border-color: rgba(148,163,184,.18);
  box-shadow: 0 24px 50px rgba(0,0,0,.42);
}

html[data-theme="light"] .theme-picker {
  background: linear-gradient(180deg, rgba(255,255,255,.96), rgba(243,247,253,.94));
}

html[data-theme="dark"] .theme-picker {
  background: linear-gradient(180deg, rgba(18,26,45,.95), rgba(24,34,56,.92));
}

@media (max-width: 760px) {
  .theme-picker { min-width: 132px; }
  .theme-dropdown-toggle { min-width: 80px; padding-inline: 8px; }
  .theme-dropdown-menu { top: calc(100% + 8px); }
  .theme-option { padding: 10px; }
  .theme-option-copy small { display: none; }
}
