/* Home and products (decision 0005, restart): the hero variants, the four doors, the shop's-day story, the ecosystem
   map and the tilt cards. Loaded after styles.css on the home page and the products page only; it uses the tokens of
   styles.css (colours, --step-*, --space-*) and logical properties only (RTL mirrors by itself).

   Motion rules: everything is complete and readable without any animation. Scroll-driven animation
   (animation-timeline) lives ONLY inside @supports (animation-timeline: scroll()) AND
   @media (prefers-reduced-motion: no-preference); elsewhere (older browsers, reduced motion) the static state shows.
   No inline style anywhere: the small scripts in site.js only set CSS custom properties through the CSSOM. */

/* ---------- shared: the "concept mock-up" mark, status badges ---------- */
.mock-tag {
  position: absolute;
  inset-block-start: 0.6rem;
  inset-inline-end: 0.6rem;
  z-index: 2;
  padding: 0.15rem 0.65rem;
  border-radius: 99rem;
  background: var(--text);
  color: var(--bg);
  font-size: var(--step--1);
  font-weight: 700;
  line-height: 1.5;
}

.badge-stage[data-stage="concept"] {
  color: var(--link);
}

.badge-stage[data-stage="design"] {
  color: var(--green-text);
}

.stage-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin-block-start: var(--space-5);
}

/* ---------- hero (all variants) ---------- */
.home-hero {
  position: relative;
  padding-block: var(--space-7) var(--space-6);
  background:
    radial-gradient(60rem 30rem at 15% 0%, var(--glow-blue), transparent 70%),
    radial-gradient(50rem 28rem at 95% 30%, var(--glow-leaf), transparent 70%),
    var(--bg);
}

.hero-grid {
  display: grid;
  gap: var(--space-6);
  align-items: center;
}

@media (min-width: 62rem) {
  .hero-grid {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  }
}

.hero-title {
  margin-block: 0 var(--space-5);
  font-family: var(--display);
  font-size: var(--step-5);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.03em;
}

html[lang="ar"] .hero-title {
  line-height: 1.3;
  letter-spacing: 0;
}

.tw {
  display: inline-block;
  overflow: clip;
  vertical-align: top;
  padding-block-end: 0.1em;
}

.tw > span {
  display: inline-block;
}

.home-hero .lead {
  max-inline-size: 38rem;
  color: var(--muted);
  font-size: var(--step-1);
}

.hero-visual {
  min-inline-size: 0;
}

/* Variant 1: the living scene */
.scene {
  display: block;
  inline-size: 100%;
  max-block-size: 72vh;
  block-size: auto;
}

.sc-ink {
  fill: none;
  stroke: var(--art-ink);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sc-blue {
  fill: var(--art-blue);
}

.sc-green {
  fill: var(--art-green);
}

.sc-card {
  fill: var(--card);
  stroke: var(--art-ink);
  stroke-width: 2.4;
}

.sc-roof {
  fill: var(--art-blue);
  stroke: var(--art-ink);
  stroke-width: 2.4;
  stroke-linejoin: round;
}

.sc-window {
  fill: var(--surface);
  stroke: var(--art-ink);
  stroke-width: 2.4;
}

.sc-door {
  fill: var(--art-green);
  stroke: var(--art-ink);
  stroke-width: 2.4;
}

.sc-ground {
  fill: none;
  stroke: var(--border);
  stroke-width: 2;
}

.sc-link {
  fill: none;
  stroke: var(--art-blue);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
}

.sc-tool {
  transform-box: fill-box;
  transform-origin: center;
}

.sc-link-1, .sc-tool-1 { --i: 0; }
.sc-link-2, .sc-tool-2 { --i: 1; }
.sc-link-3, .sc-tool-3 { --i: 2; }
.sc-link-4, .sc-tool-4 { --i: 3; }
.sc-link-5, .sc-tool-5 { --i: 4; }
.sc-link-6, .sc-tool-6 { --i: 5; }

@keyframes sc-draw {
  from { stroke-dashoffset: 1; }
  to { stroke-dashoffset: 0; }
}

@keyframes sc-pop {
  from { opacity: 0.15; transform: scale(0.85); }
  to { opacity: 1; transform: none; }
}

@supports (animation-timeline: scroll()) {
  @media (prefers-reduced-motion: no-preference) {
    /* a tall track with a sticky frame: the scene stays in view while the tools connect one by one */
    .scene-track {
      block-size: 190vh;
    }

    .scene-stick {
      position: sticky;
      inset-block-start: 4.2rem;
      display: grid;
      align-items: center;
      min-block-size: calc(100svh - 4.2rem);
    }

    .sc-link,
    .sc-tool {
      animation-timing-function: linear;
      animation-fill-mode: both;
      animation-timeline: scroll(root block);
    }

    .sc-link {
      animation-name: sc-draw;
      animation-range: calc(var(--i) * 9vh) calc(var(--i) * 9vh + 20vh);
    }

    .sc-tool {
      animation-name: sc-pop;
      animation-range: calc(var(--i) * 9vh + 10vh) calc(var(--i) * 9vh + 24vh);
    }
  }
}

/* Variant 2: big type with CSS motion */
.hero-type .hero-title {
  font-size: clamp(3.4rem, 1.5rem + 11vw, 10rem);
  line-height: 0.95;
}

html[lang="ar"] .hero-type .hero-title {
  line-height: 1.25;
}

.hero-type .hero-grid {
  grid-template-columns: 1fr;
}

.hero-type .tw > span {
  color: var(--link);
}

@supports (background-clip: text) or (-webkit-background-clip: text) {
  .hero-type .tw > span {
    background: linear-gradient(100deg, var(--blue) 0%, var(--green-text) 55%, var(--blue) 100%) 0 0 / 220% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
  }
}

.ticker {
  overflow: hidden;
  margin-block-start: var(--space-6);
  padding-block: var(--space-3);
  border-block: 1px solid var(--border);
}

.ticker-track {
  display: flex;
  inline-size: max-content;
  gap: var(--space-6);
  padding-inline-end: var(--space-6);
  color: var(--muted);
  font-family: var(--display);
  font-size: var(--step-2);
}

@keyframes tw-rise {
  from { transform: translateY(105%); }
}

@keyframes tw-sweep {
  to { background-position: 100% 0; }
}

@keyframes ticker-ltr {
  to { transform: translateX(-50%); }
}

@keyframes ticker-rtl {
  to { transform: translateX(50%); }
}

@media (prefers-reduced-motion: no-preference) {
  .tw > span {
    animation: tw-rise 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  }

  .tw-2 > span { animation-delay: 0.12s; }
  .tw-3 > span { animation-delay: 0.24s; }
  .tw-4 > span { animation-delay: 0.36s; }

  .hero-type .tw > span {
    animation: tw-rise 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both, tw-sweep 7s linear 1s infinite alternate;
  }

  .hero-type .tw-2 > span { animation-delay: 0.12s, 1s; }
  .hero-type .tw-3 > span { animation-delay: 0.24s, 1s; }

  .ticker-track {
    animation: ticker-ltr 40s linear infinite;
  }

  html[dir="rtl"] .ticker-track {
    animation-name: ticker-rtl;
  }
}

/* Variant 3: concept mock-up collage */
.collage {
  position: relative;
  inline-size: 100%;
  aspect-ratio: 5 / 4;
}

.mock {
  position: absolute;
  inline-size: 62%;
  margin: 0;
  filter: drop-shadow(0 18px 26px rgba(11, 26, 46, 0.18));
  transition: transform 0.4s ease;
}

.mock svg {
  display: block;
  inline-size: 100%;
  block-size: auto;
}

.mock-1 {
  inset-block-start: 2%;
  inset-inline-start: 0;
  transform: rotate(-4deg);
}

.mock-2 {
  inset-block-start: 24%;
  inset-inline-end: 0;
  z-index: 2;
  transform: rotate(3deg);
}

.mock-3 {
  inset-block-end: 0;
  inset-inline-start: 14%;
  z-index: 3;
  transform: rotate(-1.5deg);
}

.mk-frame {
  fill: var(--card);
  stroke: var(--border);
  stroke-width: 2;
}

.mk-line {
  fill: var(--border);
}

.mk-panel {
  fill: var(--surface);
}

.mk-tiles rect {
  fill: var(--surface);
  stroke: var(--border);
}

.mk-cta {
  fill: var(--btn-bg);
}

.mk-bar {
  fill: var(--art-blue);
}

.mk-dot {
  fill: #fff;
}

.mk-bars rect {
  fill: var(--art-blue);
}

.mk-bars rect:nth-child(even) {
  fill: var(--art-green);
}

.mk-trend {
  fill: none;
  stroke: var(--art-ink);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mock-note {
  margin-block-start: var(--space-4);
  color: var(--muted);
  font-size: var(--step--1);
}

/* ---------- the four doors ---------- */
.doors-section {
  padding-block: var(--space-6);
}

.doors {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
  gap: var(--space-4);
  margin: var(--space-5) 0 0;
  padding: 0;
  list-style: none;
}

.door {
  display: block;
  block-size: 100%;
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow-card);
  color: var(--text);
  text-decoration: none;
}

.door h3 {
  margin-block: var(--space-3) var(--space-2);
}

.door p {
  margin: 0;
  color: var(--muted);
}

.door:hover,
.door:focus-visible {
  border-color: var(--blue);
  box-shadow: var(--shadow-card-hover);
}

.door-n {
  display: inline-grid;
  place-items: center;
  inline-size: 2.4rem;
  block-size: 2.4rem;
  border-radius: 50%;
  background: var(--btn-bg);
  color: var(--btn-text);
  font-weight: 700;
}

@media (prefers-reduced-motion: no-preference) {
  .door {
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  }

  .door:hover {
    transform: translateY(-4px);
  }
}

/* ---------- the shop's-day story ---------- */
.story-grid {
  display: grid;
  grid-template-columns: 2.5rem minmax(0, 1fr);
  gap: var(--space-5);
  margin-block-start: var(--space-6);
  timeline-scope: --story;
}

.story-rail {
  position: relative;
}

.story-line {
  position: sticky;
  inset-block-start: 6rem;
  block-size: 50vh;
  inline-size: 4px;
  margin-inline: auto;
  border-radius: 4px;
  background: var(--border);
  overflow: clip;
}

.story-line i {
  display: block;
  block-size: 100%;
  background: linear-gradient(var(--blue), var(--green));
  transform-origin: top;
}

.story-steps {
  display: grid;
  gap: var(--space-6);
  margin: 0;
  padding: 0;
  list-style: none;
}

.story-step {
  display: grid;
  grid-template-columns: 3.5rem minmax(0, 1fr);
  gap: var(--space-4);
  align-items: start;
  min-block-size: 30vh;
}

.story-ico {
  display: grid;
  place-items: center;
  inline-size: 3.5rem;
  block-size: 3.5rem;
  border-radius: var(--radius);
  background: var(--surface);
}

.story-ico svg {
  inline-size: 2rem;
  block-size: 2rem;
}

.story-step h3 {
  margin-block-end: var(--space-2);
  font-size: var(--step-2);
}

.story-step p {
  margin-block-end: var(--space-2);
  font-size: var(--step-1);
}

.story-link {
  font-size: var(--step-0);
}

@keyframes story-grow {
  from { transform: scaleY(0); }
  to { transform: scaleY(1); }
}

@keyframes story-in {
  from { opacity: 0.15; transform: translateY(2.5rem); }
  to { opacity: 1; transform: none; }
}

@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .story-steps {
      view-timeline: --story block;
    }

    .story-line i {
      animation: story-grow linear both;
      animation-timeline: --story;
      animation-range: cover 10% cover 90%;
    }

    .story-step {
      animation: story-in linear both;
      animation-timeline: view();
      animation-range: entry 5% entry 55%;
    }
  }
}

/* ---------- the ecosystem map ---------- */
.eco-map {
  display: grid;
  gap: var(--space-6);
  align-items: center;
}

@media (min-width: 52rem) {
  .eco-map {
    grid-template-columns: minmax(0, 20rem) minmax(0, 1fr);
  }
}

.eco-svg {
  display: block;
  inline-size: 100%;
  max-inline-size: 22rem;
  margin-inline: auto;
}

.eco-node {
  cursor: pointer;
}

.eco-node rect {
  fill: var(--card);
  stroke: var(--art-ink);
  stroke-width: 2.4;
}

.eco-node text {
  fill: var(--text);
  font-family: var(--font);
  font-size: 24px;
  font-weight: 700;
}

.eco-node.is-active rect {
  fill: var(--btn-bg);
  stroke: var(--btn-bg);
}

.eco-node.is-active text {
  fill: var(--btn-text);
}

.eco-link {
  fill: none;
  stroke: var(--art-blue);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 6 8;
}

@keyframes eco-flow {
  to { stroke-dashoffset: -28; }
}

@media (prefers-reduced-motion: no-preference) {
  .eco-link {
    animation: eco-flow 1.6s linear infinite;
  }
}

.eco-hint {
  color: var(--muted);
}

.eco-levels {
  display: grid;
  gap: var(--space-3);
  margin: 0 0 var(--space-4);
  padding: 0;
  list-style: none;
}

.eco-btn {
  display: block;
  inline-size: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  font: inherit;
  text-align: start;
  cursor: pointer;
}

.eco-btn:hover {
  border-color: var(--blue);
}

.eco-level.is-open .eco-btn {
  border-color: var(--blue);
  box-shadow: inset 4px 0 0 var(--blue);
}

html[dir="rtl"] .eco-level.is-open .eco-btn {
  box-shadow: inset -4px 0 0 var(--blue);
}

.eco-gloss {
  margin: var(--space-2) 0 0;
  padding-inline: var(--space-4);
  color: var(--muted);
}

/* with script: one gloss at a time */
.eco-map.is-ready .eco-gloss {
  display: none;
}

.eco-map.is-ready .eco-level.is-open .eco-gloss {
  display: block;
}

/* ---------- tilt cards ---------- */
.tilt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
  gap: var(--space-5);
  margin: var(--space-5) 0 0;
  padding: 0;
  list-style: none;
  perspective: 1100px;
}

.tilt {
  position: relative;
}

.tilt-face {
  position: relative;
  block-size: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.tilt-art {
  position: relative;
  display: grid;
  place-items: center;
  padding: var(--space-5) var(--space-5) var(--space-4);
  background: var(--surface);
}

.tilt-art svg {
  inline-size: 100%;
  max-block-size: 8rem;
}

.tilt-body {
  padding: var(--space-4) var(--space-5) var(--space-5);
}

.tilt-body h3 {
  margin-block: var(--space-2);
}

.tilt-body p {
  margin: 0;
  color: var(--muted);
}

.tilt h3 a {
  color: var(--text);
  text-decoration: none;
}

.tilt h3 a::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}

.tilt:hover,
.tilt:focus-within {
  --rx: 4deg;
  --ry: -7deg;
}

.tilt:hover .tilt-face,
.tilt:focus-within .tilt-face {
  border-color: var(--blue);
  box-shadow: var(--shadow-card-hover);
}

@media (prefers-reduced-motion: no-preference) {
  .tilt-face {
    transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
    will-change: transform;
  }
}

/* Reduced motion: nothing moves, nothing is hidden */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }

  .scene-track {
    block-size: auto !important;
  }

  .tilt-face {
    transform: none !important;
  }
}
