@layer reset, base, layout, components, responsive;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { scroll-behavior: smooth; }
  body, h1, h2, h3, p, dl, dd, ol, fieldset, pre { margin: 0; }
  fieldset { min-inline-size: 0; border: 0; padding: 0; }
  a { color: inherit; text-decoration: none; }
  button, input, textarea { font: inherit; }
  button { cursor: pointer; }
  img { display: block; max-inline-size: 100%; }
  [hidden] { display: none !important; }
}

@layer base {
  :root {
    color-scheme: dark;
    --background: #080a13;
    --surface: #0e1120;
    --surface-raised: #14182a;
    --text: #f2f3fd;
    --muted: #b5bdd4;
    --quiet: #a2aec9;
    --line: #272d43;
    --accent: #a8a9ff;
    --blue: #93dfff;
    --ink: #13162d;
    --mono: 'Cascadia Code', Consolas, monospace;
    --radius: 18px;
  }
  body {
    color: var(--text);
    background: var(--background);
    font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.65;
    min-inline-size: 0;
  }
  :lang(ar) body { font-family: Tahoma, 'Segoe UI', Arial, sans-serif; }
  ::selection { background: #b1afff; color: #101228; }
  :focus-visible { outline: 2px solid var(--blue); outline-offset: 5px; }
  main:focus { outline: none; }
  h1, h2, h3 { line-height: 1.13; font-weight: 700; text-wrap: balance; }
  :lang(ar) :is(h1,h2,h3) { line-height: 1.28; }
  h2 { font-size: clamp(2.4rem, 5vw, 5.35rem); letter-spacing: -.06em; }
  :lang(ar) h2 { letter-spacing: normal; }
  h3 { font-size: clamp(1.25rem, 2.35vw, 2.2rem); }
  section[id], article[id] { scroll-margin-block-start: 32px; }
  .sr-only {
    position: absolute; inline-size: 1px; block-size: 1px; padding: 0;
    overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
  }
  .skip {
    position: fixed; z-index: 10; inset-block-start: .75rem; inset-inline-start: .75rem;
    color: var(--ink); background: var(--blue); padding: .65rem 1rem; border-radius: 8px;
    transform: translateY(-200%); clip-path: inset(50%);
  }
  .skip:focus { transform: translateY(0); clip-path: none; }
}

@layer layout {
  .shell { width: min(100% - clamp(2rem, 9vw, 9rem), 1280px); margin-inline: auto; }
  .section { padding-block: clamp(4.4rem, 9vw, 9rem); }
  .divided { border-block-start: 1px solid var(--line); }
  .section-intro { max-inline-size: 54rem; margin-block-end: clamp(1.8rem, 4vw, 3.7rem); }
  .two-col { display: grid; grid-template-columns: minmax(0,.82fr) minmax(0,1.18fr); gap: clamp(1.7rem, 6vw, 6rem); align-items: start; }
  .two-col .section-intro { margin: 0; }
  .eyebrow { color: #bac3ff; font-size: .8rem; font-weight: 700; margin-block-end: 1.14rem; }
  :lang(en) .eyebrow { font-family: var(--mono); text-transform: uppercase; letter-spacing: .16em; }
  .lede { color: var(--muted); max-inline-size: 41rem; margin-block-start: 1rem; font-size: clamp(1rem, 1.7vw, 1.15rem); line-height: 1.8; }
  .actions { display: flex; align-items: center; flex-wrap: wrap; gap: .72rem; }
}

@layer components {
  .site-header { position: absolute; z-index: 4; inset: 0 0 auto; }
  .header-inner {
    min-block-size: 75px; display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; border-block-end: 1px solid rgba(204,218,255,.19);
  }
  .brand { display: inline-flex; align-items: center; gap: .68rem; white-space: nowrap; font-size: .91rem; font-weight: 800; letter-spacing: .03em; }
  .brand b { color: #8994b1; margin-inline: .13rem; font-weight: 400; }
  .brand-mark { position: relative; width: 24px; height: 24px; display: grid; grid-template: 1fr 1fr / 1fr 1fr; gap: 6px; flex: none; }
  .brand-mark i { border: solid #aab4ff; border-width: 2px 0 0 2px; border-radius: 2px 0 0; }
  .brand-mark i:nth-child(2) { transform: rotate(90deg); }
  .brand-mark i:nth-child(3) { transform: rotate(-90deg); }
  .brand-mark i:nth-child(4) { transform: rotate(180deg); }
  .brand-mark::after { content: ''; position: absolute; inset: 10px; background: var(--blue); transform: rotate(45deg); box-shadow: 0 0 8px #9ba9ff; }
  .site-nav, .head-actions { display: flex; align-items: center; gap: clamp(.7rem, 2vw, 1.7rem); }
  .site-nav a, .language, .header-cta, .nav-toggle { font-size: .83rem; font-weight: 700; white-space: nowrap; }
  .site-nav a { color: #d9ddef; }
  .site-nav a:hover, .language:hover, .site-footer a:hover { color: var(--blue); }
  .language { color: #f0f2ff; }
  .header-cta, .nav-toggle { padding: .55rem .9rem; border: 1px solid #7e88b2; border-radius: 8px; }
  .header-cta:hover, .nav-toggle:hover { background: #232b49; }
  .nav-toggle { display: none; background: #171b30; color: var(--text); }
  .arrow { display: inline-block; line-height: 1; font-size: 1.15em; }
  [dir=rtl] .arrow { transform: scaleX(-1); }

  .hero {
    overflow: hidden; position: relative; isolation: isolate; min-block-size: min(840px, 100svh);
    background: #080a16; display: grid;
  }
  .hero-inner { display: grid; grid-template-rows: 1fr auto; padding-block: clamp(8rem, 18vh, 11rem) 1.85rem; }
  .hero-content { align-self: center; max-inline-size: 46rem; padding-block-end: clamp(2rem, 6vh, 4.5rem); }
  .hero-tag { display: inline-flex; gap: .65rem; align-items: center; font: 700 .72rem var(--mono); letter-spacing: .19em; color: #cad2ff; }
  .hero-tag span { display: block; width: 26px; height: 1px; background: var(--blue); box-shadow: 0 0 9px var(--blue); }
  .hero h1 { font-size: clamp(3.8rem, 6.1vw, 7.4rem); font-weight: 750; letter-spacing: -.072em; line-height: .98; }
  :lang(ar) .hero h1 { font-size: clamp(3.2rem, 5.9vw, 6.4rem); letter-spacing: -.025em; line-height: 1.16; }
  .hero h1 span, .vision-inner h2 span { display: block; }
  .hero h1 .hero-first { color: #bdc4ff; }
  .hero-copy { max-inline-size: 34rem; color: #d0d5e9; margin-block: 1.35rem 2rem; font-size: clamp(1rem, 1.55vw, 1.14rem); line-height: 1.82; }
  .hero-foot {
    display: flex; justify-content: space-between; align-items: center; gap: 1rem;
    color: #c2cbe4; font-size: .78rem; border-block-start: 1px solid rgba(204,218,255,.2); padding-block-start: .9rem;
  }
  .hero-foot a { display: inline-flex; align-items: center; gap: .55rem; min-block-size: 44px; }
  .hero-foot a:hover { color: var(--blue); }
  .down { display: grid; place-items: center; inline-size: 27px; block-size: 27px; border: 1px solid #65749e; border-radius: 50%; }
  .button {
    display: inline-flex; justify-content: center; align-items: center; gap: .65em; min-block-size: 48px;
    padding: .64rem 1rem; border: 1px solid transparent; border-radius: 9px;
    line-height: 1.35; font-size: .89rem; font-weight: 700;
    transition: background .18s, border-color .18s, transform .18s;
  }
  .button:hover { transform: translateY(-2px); }
  .primary { color: #101427; background: #bdc2ff; border-color: #bdc2ff; box-shadow: 0 5px 22px rgba(136,142,255,.14); }
  .primary:hover { background: #e0e3ff; border-color: #e0e3ff; }
  .secondary { color: #e9ecff; background: #14192c; border-color: #555f82; }
  .secondary:hover { background: #222947; border-color: #a4aad8; }

  .world { background: radial-gradient(ellipse at 78% 0%,#161b36 0%,transparent 62%); }
  .world-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: .85rem; }
  .world-card {
    position: relative; padding: clamp(1.2rem, 3vw, 2.1rem); border: 1px solid var(--line); min-block-size: 170px;
    background: linear-gradient(145deg,#151a30,#0c0f1c 63%); border-radius: var(--radius); transition: background .18s, border-color .18s;
  }
  .world-card:hover { background: #1a203a; border-color: #7784c2; }
  .world-card h3 { margin-block: .7rem .5rem; padding-inline-end: 1.35rem; }
  .world-card p { color: var(--muted); }
  .world-card .arrow { position: absolute; inset-inline-end: 1.25rem; inset-block-start: 1.3rem; color: var(--blue); }

  .project-tabs { display: flex; gap: .65rem; flex-wrap: wrap; margin-block-end: 1.15rem; }
  .project-tabs a {
    display: inline-flex; align-items: center; min-block-size: 45px; padding: .5rem .86rem;
    border-radius: 7px; background: #0e1222; border: 1px solid #2d3550; color: #cad3ed; font-size: .87rem;
  }
  .project-tabs a:hover { border-color: #a7aee5; }
  .project-tabs a[aria-selected=true] { background: #282e52; color: #f6f6ff; border-color: #8b95d7; }
  .project-panel {
    min-block-size: 355px; display: grid; grid-template-columns: minmax(0,1fr) minmax(0,.96fr);
    border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: clip; margin-block-end: 1rem;
  }
  .project-panel:focus-visible { outline-offset: 4px; }
  .project-copy { padding: clamp(1.55rem,4.2vw,3.75rem); align-self: center; }
  .project-copy h3 { font-size: clamp(1.9rem,4vw,3.9rem); margin-block: .6rem 1rem; overflow-wrap: anywhere; }
  .project-copy > p:not(.project-status), .project-copy dd { color: var(--muted); }
  .project-status { color: #c5ccff; display: flex; align-items: center; gap: .55rem; font-size: .82rem; }
  .project-status span, .status-dot i { inline-size: 7px; block-size: 7px; flex: none; border-radius: 50%; background: #a2cfff; box-shadow: 0 0 11px #85aaff; }
  .project-copy dl { border-block-start: 1px solid var(--line); margin-block-start: 1.65rem; padding-block-start: .85rem; }
  .project-copy dt { color: #e9ebff; font-size: .85rem; font-weight: 700; }

  .engineering .section-intro { position: sticky; inset-block-start: 2rem; }
  .service-list details { border-block-start: 1px solid var(--line); }
  .service-list details:last-child { border-block-end: 1px solid var(--line); }
  .service-list summary {
    display: grid; grid-template-columns: minmax(0,1fr) auto; gap: .9rem; align-items: center;
    cursor: pointer; padding: 1.2rem .26rem; min-block-size: 64px; font-size: clamp(1rem,2vw,1.24rem); font-weight: 700;
  }
  .service-list summary::-webkit-details-marker { display: none; }
  .service-list summary:hover { color: var(--blue); }
  .service-list summary i { width: 17px; height: 17px; position: relative; }
  .service-list summary i::before, .service-list summary i::after {
    content: ''; position: absolute; inset: 8px 0 auto; height: 1px; background: var(--accent); transition: transform .22s;
  }
  .service-list summary i::after { transform: rotate(90deg); }
  .service-list details[open] summary i::after { transform: rotate(0deg); }
  .service-body { padding: 0 .6rem 1.2rem; color: var(--muted); }
  .service-output { color: #cdd5ff; margin-block-start: .6rem; font-size: .9rem; }
  
  .card { padding: clamp(1.1rem, 3vw, 2.3rem); border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); min-inline-size: 0; }
  .panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: .8rem; padding-block-end: 1rem; border-block-end: 1px solid var(--line); }
  .panel-head h3 { font-size: clamp(1.1rem,2vw,1.55rem); }
  .text-button { flex: none; background: transparent; border: 0; color: #c1c9ff; font-size: .82rem; padding: .52rem .25rem; min-block-size: 44px; text-decoration: underline; text-underline-offset: .23em; }
  .text-button:hover { color: var(--blue); }
  .lab-section { background: radial-gradient(ellipse at 24% 55%,#17183a,transparent 60%); }
  .lab-next { display: inline-flex; align-items: center; gap: .55rem; min-block-size: 44px; margin-block-start: .7rem; color: #c6d0ff; font-weight: 700; }
  .lab-next:hover { text-decoration: underline; text-underline-offset: .22em; }
  .lab-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: clamp(1rem,3vw,2.3rem); margin-block-start: 1.3rem; }
  .range-list label { display: flex; justify-content: space-between; align-items: center; gap: .5rem; font-weight: 700; font-size: .9rem; }
  .range-list output { font: 1.03rem var(--mono); color: #d2d6ff; }
  .range-list input { accent-color: #b1b8ff; width: 100%; height: 34px; margin: .15rem 0 .6rem; cursor: pointer; }
  .range-list p { color: var(--quiet); font-size: .85rem; }
  .lab-result { align-self: center; padding: clamp(1rem,3vw,1.7rem); background: var(--surface-raised); border: 1px solid #333a57; border-radius: 13px; }
  .meter { height: 8px; border-radius: 99px; background: #343a54; overflow: hidden; margin-block-end: 1rem; }
  .meter div { background: linear-gradient(to right,#9de2ff,#b8aaff); height: 100%; width: 75%; transition: width .18s; }
  [dir=rtl] .meter div { background: linear-gradient(to left,#9de2ff,#b8aaff); }
  .lab-result[data-load=over] .meter div { background: #ffb5c4; }
  .metrics { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: .55rem; }
  .metrics div { display: flex; flex-direction: column-reverse; justify-content: start; gap: .3rem; }
  .metrics dt { font-size: .77rem; color: var(--muted); line-height: 1.45; }
  .metrics dd { font: 600 clamp(1.15rem,3vw,2.15rem) var(--mono); text-align: start; }
  [dir=rtl] .metrics dd { text-align: right; }
  .lab-status { font-size: .88rem; color: #a8e7ff; margin-block-start: 1rem; }
  .lab-result[data-load=over] .lab-status { color: #ffc3cf; }

  .status-dot { display: inline-flex; align-items: center; gap: .6rem; }
  .chat-log { min-block-size: 8.8rem; max-block-size: 16rem; overflow: auto; padding: .9rem .15rem; display: flex; flex-direction: column; gap: .62rem; }
  .chat-message {
    align-self: flex-start; max-inline-size: 90%; padding: .66rem .85rem; border-radius: 12px;
    border: 1px solid #333b59; background: #171d35; color: #e6eaff; white-space: pre-wrap; overflow-wrap: anywhere;
  }
  .chat-message[data-speaker=user] { align-self: flex-end; background: #252844; border-color: #434971; }
  .chips { display: flex; flex-wrap: wrap; gap: .42rem; margin-block: .55rem 1rem; }
  .chips button { min-block-size: 38px; background: #151a2d; border: 1px solid #3d486a; border-radius: 20px; color: #d9e0ff; padding-inline: .67rem; font-size: .79rem; }
  .chips button:hover { background: #262f50; }
  .chat-form { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: .55rem; }
  :is(input:not([type=range],[type=radio]),textarea) {
    display: block; inline-size: 100%; border: 1px solid #485475; border-radius: 8px;
    padding: .63rem .8rem; background: #0a0e1d; color: var(--text); min-block-size: 48px;
  }
  input::placeholder, textarea::placeholder { color: #a1abc5; opacity: 1; }
  textarea { resize: vertical; }
  .brief-section { background: linear-gradient(120deg,#111531,#0a0c18 63%); }
  .steps { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); list-style: none; padding: 0; margin-block-end: 1rem; border-block-end: 1px solid var(--line); }
  .steps li { padding: 0 .3rem .8rem; color: var(--quiet); display: flex; align-items: center; gap: .38rem; font-size: .84rem; border-block-end: 2px solid transparent; }
  .steps li[aria-current] { color: #eef0ff; border-block-end-color: var(--accent); }
  .steps span { color: var(--accent); font: .68rem var(--mono); }
  .wizard legend, .wizard label, .contact label { font-weight: 700; }
  .wizard legend:not(.sr-only) { margin-block-end: .75rem; }
  .wizard textarea { margin-block: .35rem .8rem; }
  .wizard .actions { margin-block-start: .85rem; }
  .tracks { display: flex; flex-wrap: wrap; gap: .55rem; margin-block-end: 1rem; }
  .tracks label { display: flex; align-items: center; gap: .36rem; min-block-size: 44px; padding: .38rem .63rem; border: 1px solid #434d72; border-radius: 7px; font-size: .87rem; cursor: pointer; }
  .tracks label:has(:checked) { border-color: #bcc3ff; background: #282f53; }
  .tracks input { margin: 0; accent-color: #b3bcff; }
  .brief-summary div { padding-block: .45rem; border-block-start: 1px solid var(--line); }
  .brief-summary dt { color: #c7d0fe; font-size: .83rem; }
  .brief-summary dd { white-space: pre-wrap; overflow-wrap: anywhere; }
  .vision-section {
    position: relative; isolation: isolate; overflow: hidden;
    background: radial-gradient(ellipse at 72% 29%,#282550 0%,#11152c 35%,#090c18 78%);
  }
  .vision-section::before {
    content: ''; position: absolute; z-index: -1; inset: 0;
    background: repeating-linear-gradient(119deg,transparent 0 63px,rgba(138,158,250,.16) 64px,transparent 65px 102px);
    mask-image: linear-gradient(to left,#000,transparent 77%);
  }
  [dir=rtl] .vision-section::before { transform: scaleX(-1); }
  .vision-inner h2 span:first-child { color: #c0c4ff; }
  .principles { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 1rem; margin-block-start: 2.1rem; max-inline-size: 60rem; }
  .principles div { border-block-start: 1px solid #676e9b; background: #0d1121; padding: .85rem 1rem; border-radius: 0 0 10px 10px; }
  .principles dt { font-weight: 700; margin-block-end: .25rem; }
  .principles dd { color: var(--muted); font-size: .89rem; }
  .contact-fields { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .8rem; margin-block-end: .88rem; }
  .contact :is(input,textarea) { margin-block-start: .38rem; }
  .privacy { margin-block: .85rem; color: var(--muted); font-size: .85rem; }
  .privacy span { color: var(--blue); }
  .feedback { color: #b5e8ff; }
  .feedback:empty { display: none; }
  .contact pre {
    border: 1px solid #454f74; border-radius: 8px; background: #0a0e1d; color: #dae2ff;
    padding: .8rem; margin-block-start: .95rem; font: inherit; white-space: pre-wrap; overflow-wrap: anywhere;
  }
  .site-footer { border-block-start: 1px solid var(--line); }
  .footer-inner { display: flex; justify-content: space-between; align-items: center; gap: 1rem; min-block-size: 86px; flex-wrap: wrap; padding-block: .85rem; }
  .footer-inner p, .footer-inner > a:last-child { color: var(--muted); font-size: .84rem; }
}

@layer responsive {
  @media (max-width: 940px) {
    .site-nav { gap: .65rem; }
    .head-actions { gap: .75rem; }
    .header-cta { display: none; }
    .hero h1 { font-size: clamp(3.25rem,7.5vw,5.6rem); }
  }
  @media (max-width: 800px) {
    .two-col, .world-grid { grid-template-columns: 1fr; }
    .world-card { min-block-size: 0; }
    .world-card h3 { margin-block-start: .6rem; }
    .engineering .section-intro { position: static; }
    .header-inner { min-block-size: 65px; flex-wrap: wrap; }
    .js .site-nav {
      display: none; position: absolute; inset: 65px 1rem auto; padding: .65rem; background: #101528;
      border: 1px solid #45517a; border-radius: 10px; z-index: 5; align-items: stretch;
    }
    .js .site-nav.is-open { display: grid; gap: .2rem; }
    .site-nav a { padding: .65rem .65rem; }
    .site-nav a:hover { background: #242d4d; border-radius: 6px; }
    .js .nav-toggle { display: inline-flex; align-items: center; gap: .35em; min-block-size: 44px; }
    .site-nav { order: 3; flex-wrap: wrap; }
    .hero { min-block-size: max(690px,100svh); }
    .hero-inner { padding-block: 20rem 1.15rem; }
    .hero-content { align-self: end; padding-block-end: 1.5rem; }
    .hero-copy { margin-block: .85rem 1.2rem; }
    .hero h1, :lang(ar) .hero h1 { font-size: clamp(2.8rem,9.4vw,4.4rem); }
    .hero h1 span:nth-child(2), .hero h1 span:nth-child(3) { display: inline; }
    .project-panel { grid-template-columns: 1fr; }
    .project-art { min-block-size: 220px; }
    .lab-next { display: inline-flex; align-items: center; gap: .55rem; min-block-size: 44px; margin-block-start: .7rem; color: #c6d0ff; font-weight: 700; }
  .lab-next:hover { text-decoration: underline; text-underline-offset: .22em; }
  .lab-grid { grid-template-columns: 1fr; }
  }
  @media (max-width: 460px) {
    .head-actions { gap: .50rem; }
    .brand { gap: .42rem; font-size: .82rem; }
    .brand-mark { width: 20px; height: 20px; }
    .brand-mark::after { inset: 8px; }
    .hero-inner { padding-block-start: 17.5rem; }
    .hero-tag { letter-spacing: .11em; margin-block-end: .73rem; }
    .hero-foot { font-size: .72rem; }
    .contact-fields, .principles { grid-template-columns: 1fr; }
    .footer-inner p { display: none; }
    .steps li { flex-direction: column; align-items: start; gap: .2rem; }
  }
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
    .button:hover { transform: none; }
  }
}
