/* ==========================================================================
   RONIC — adaptive timelines (tablet + mobile)           v20261129a
   --------------------------------------------------------------------------
   Desktop (> 1100px) is untouched. At <= 1100px the two timelines get their
   own layouts instead of being squeezed:

   HOME  (#process .timeline-shell, 12 stages)
     - scrollable "stage chips" rail that auto-centres the active chip
     - live progress bar + "03 / 12" counter
     - wide image on top, copy below (tablet: copy + stat card side by side)
     - previous / next controls, swipe + arrow-key support

   SERVICES (#engineering-framework, 5 steps)
     - horizontal stepper (numbers + short labels) directly above the card
     - image + copy side by side on tablet, stacked on phones
     - previous / next controls, swipe support
   ========================================================================== */

/* ---------- controls that only exist for the compact layouts ---------- */
.timeline-prev,
.engineering-card-nav { display: none; }

@media (max-width: 1100px) {

  /* =====================================================================
     HOME — 12-stage production timeline
     ===================================================================== */

  #process { display: block !important; }              /* section was hidden <=768px */

  #process .timeline-shell {
    --tl-gold: #ffd900;
    --tl-gold-2: #ff8c00;
    --tl-line: rgba(109, 181, 222, .22);
    --tl-chip-bg: rgba(7, 26, 43, .72);
    --tl-chip-bd: rgba(112, 174, 214, .28);
    --tl-chip-fg: #9ab7cf;
    --tl-chip-on: #ffffff;
    padding: 1.25rem;
    border-radius: 1.5rem;
    overflow: hidden;
  }

  /* header row: kicker + title on the left, live counter on the right */
  #process .timeline-topline {
    position: relative;
    align-items: flex-end;
    margin-bottom: 1.125rem;
    padding-bottom: 1rem;
  }
  #process .timeline-topline strong { font-size: 1.0625rem; line-height: 1.3; }
  #process .timeline-total {
    flex: 0 0 auto;
    padding: .375rem .75rem;
    border: 1px solid rgba(255, 217, 0, .35);
    border-radius: 999px;
    background: rgba(255, 217, 0, .08);
    font-size: .75rem;
    letter-spacing: .12em;
    font-variant-numeric: tabular-nums;
  }
  /* progress bar under the header (track + fill) */
  #process .timeline-topline::before,
  #process .timeline-topline::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    border-radius: 3px;
  }
  #process .timeline-topline::before { right: 0; background: var(--tl-line); }
  #process .timeline-topline::after {
    width: 100%;
    transform-origin: left center;
    transform: scaleX(var(--tl-progress, .0833));
    background: linear-gradient(90deg, var(--tl-gold-2), var(--tl-gold));
    box-shadow: 0 0 .75rem rgba(255, 190, 40, .45);
    transition: transform .45s cubic-bezier(.2, .7, .2, 1);
  }

  /* stage chips: one horizontal, snap-scrolling rail */
  #process .timeline-rail {
    display: flex;
    gap: .5rem;
    margin: 0 -1.25rem 1.125rem;
    padding: .25rem 1.25rem .375rem;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    scroll-padding-inline: 1.25rem;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 1.25rem, #000 calc(100% - 2rem), transparent 100%);
            mask-image: linear-gradient(90deg, transparent 0, #000 1.25rem, #000 calc(100% - 2rem), transparent 100%);
  }
  #process .timeline-rail::-webkit-scrollbar { display: none; }
  #process .timeline-rail-line { display: none; }

  #process .timeline-point {
    flex: 0 0 auto;
    flex-direction: row;
    align-items: center;
    gap: .625rem;
    min-height: 2.75rem;
    padding: .375rem .9375rem .375rem .375rem;
    border: 1px solid var(--tl-chip-bd);
    border-radius: 999px;
    background: var(--tl-chip-bg);
    color: var(--tl-chip-fg);
    scroll-snap-align: center;
    white-space: nowrap;
    text-align: left;
    -webkit-tap-highlight-color: transparent;
    transition: background .25s, border-color .25s, color .25s, transform .25s;
  }
  #process .timeline-point > span {
    flex: 0 0 auto;
    width: 1.875rem;
    height: 1.875rem;
    font-size: .6875rem;
  }
  #process .timeline-point small {
    max-width: none;
    font: 600 .8125rem/1.2 Inter, sans-serif;
    color: inherit;
    overflow-wrap: normal;
    white-space: nowrap;
  }
  #process .timeline-point.is-active {
    border-color: rgba(255, 217, 0, .55);
    background: rgba(255, 217, 0, .09);
    color: var(--tl-chip-on);
  }
  #process .timeline-point.is-active small { color: var(--tl-gold); }
  #process .timeline-point:focus-visible { outline: 2px solid var(--tl-gold); outline-offset: 2px; }

  /* detail card: wide image on top, copy below */
  #process .timeline-panels { touch-action: pan-y; }
  #process .timeline-detail {
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
    min-width: 0;
    border-radius: 1.25rem;
  }
  #process .timeline-photo-wrap {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 8;
    min-height: 0;
  }
  #process .timeline-photo-wrap::after {
    background:
      linear-gradient(180deg, rgba(3, 16, 29, 0) 40%, rgba(3, 16, 29, .72) 100%);
  }
  #process .timeline-photo-index { left: 1rem; bottom: .875rem; }

  #process .timeline-detail-copy {
    min-width: 0;
    padding: 1.25rem 1.375rem 1.375rem;
  }
  #process .timeline-detail-copy h3 { font-size: clamp(1.3125rem, 3.4vw, 1.75rem); margin: .625rem 0 .5rem; }
  #process .timeline-detail-copy > p {
    max-width: none;
    font-size: .875rem;
    line-height: 1.75;
    margin: 0;
  }
  #process .timeline-duration {
    margin-top: 1.125rem;
    font-size: .625rem;
    letter-spacing: .1em;
  }
  #process .timeline-duration strong { font-size: 1rem; }
  #process .timeline-progress { margin-top: .625rem; }

  /* controls: [prev]  01 OF 12  ............  [Next stage ->] */
  #process .timeline-detail-nav {
    flex-wrap: nowrap;
    gap: .75rem;
    margin-top: 1.125rem;
    padding-top: 1.125rem;
    border-top: 1px solid var(--tl-line);
    font-size: .6875rem;
  }
  #process .timeline-detail-nav > span { order: 1; margin-right: auto; }
  #process .timeline-detail-nav em { font-size: .6875rem; }
  #process .timeline-prev,
  #process .timeline-next {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.75rem;
    border: 1px solid var(--tl-chip-bd);
    border-radius: 999px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background .25s, border-color .25s, transform .2s;
  }
  #process .timeline-prev {
    order: 0;
    width: 2.75rem;
    padding: 0;
    background: var(--tl-chip-bg);
    color: #d9f5ff;
  }
  #process .timeline-prev svg { width: 1.125rem; height: 1.125rem; }
  #process .timeline-next {
    order: 2;
    gap: .5rem;
    padding: 0 .5rem 0 1.125rem;
    border-color: rgba(255, 217, 0, .45);
    background: rgba(255, 217, 0, .1);
    font-size: .75rem;
  }
  #process .timeline-next b {
    display: inline-grid;
    place-items: center;
    width: 1.875rem;
    height: 1.875rem;
    margin: 0;
    border-radius: 50%;
    background: linear-gradient(145deg, var(--tl-gold-2), var(--tl-gold));
    color: #041522;
  }
  #process .timeline-next b svg { width: 1rem; height: 1rem; }
  #process .timeline-prev:active,
  #process .timeline-next:active { transform: scale(.96); }

  /* ---- tablet only: copy + stat card side by side under the image ---- */
  @media (min-width: 700px) {
    #process .timeline-photo-wrap { aspect-ratio: 16 / 7; }
    #process .timeline-detail-copy {
      display: grid;
      grid-template-columns: minmax(0, 1.2fr) minmax(13rem, .8fr);
      grid-template-rows: auto auto 1fr auto;
      column-gap: 2rem;
      align-items: start;
      padding: 1.5rem 1.75rem 1.5rem;
    }
    #process .timeline-detail-copy .production-tag { grid-column: 1; grid-row: 1; }
    #process .timeline-detail-copy h3 { grid-column: 1; grid-row: 2; }
    #process .timeline-detail-copy > p { grid-column: 1; grid-row: 3; }
    #process .timeline-duration {
      grid-column: 2;
      grid-row: 1 / span 2;
      flex-direction: column;
      align-items: flex-start;
      justify-content: center;
      gap: .375rem;
      width: auto;
      margin: 0;
      padding: 1rem 1.125rem;
      border: 1px solid rgba(255, 217, 0, .22);
      border-radius: 1rem;
      background: rgba(255, 217, 0, .05);
    }
    #process .timeline-duration strong { font-size: 1.5rem; line-height: 1.1; }
    #process .timeline-progress { grid-column: 2; grid-row: 3; align-self: start; margin-top: .875rem; }
    #process .timeline-detail-nav { grid-column: 1 / -1; grid-row: 4; }
  }

  /* ---- phones ---- */
  @media (max-width: 699px) {
    #process .timeline-shell { padding: 1rem; border-radius: 1.25rem; }
    #process .timeline-rail { margin-inline: -1rem; padding-inline: 1rem; scroll-padding-inline: 1rem; }
    #process .timeline-topline { gap: .75rem; }
    #process .timeline-topline strong { font-size: .9375rem; }
    #process .timeline-photo-wrap { aspect-ratio: 16 / 10; }
    #process .timeline-detail-copy { padding: 1.125rem 1.125rem 1.25rem; }
    #process .timeline-detail-copy > p { font-size: .8125rem; }
    #process .timeline-duration { flex-wrap: nowrap; }
    #process .timeline-next { padding-left: 1rem; }
  }

  /* ---- light theme ---- */
  html[data-theme="light"] #process .timeline-shell {
    --tl-line: rgba(0, 105, 190, .16);
    --tl-chip-bg: #ffffff;
    --tl-chip-bd: rgba(0, 105, 190, .2);
    --tl-chip-fg: #526b83;
    --tl-chip-on: #122b45;
  }
  html[data-theme="light"] #process .timeline-total {
    border-color: rgba(255, 140, 0, .45);
    background: rgba(255, 140, 0, .09);
  }
  html[data-theme="light"] #process .timeline-point.is-active {
    border-color: rgba(255, 140, 0, .6);
    background: rgba(255, 140, 0, .09);
  }
  html[data-theme="light"] #process .timeline-point.is-active small { color: #c76a00; }
  html[data-theme="light"] #process .timeline-prev { color: #122b45; }
  html[data-theme="light"] #process .timeline-next { color: #122b45; border-color: rgba(255, 140, 0, .5); background: rgba(255, 140, 0, .09); }
  html[data-theme="light"] #process .timeline-detail-nav { border-top-color: rgba(0, 105, 190, .14); }
  html[data-theme="light"] #process .timeline-duration { background: rgba(255, 140, 0, .06); border-color: rgba(255, 140, 0, .28); }


  /* =====================================================================
     SERVICES — 5-step engineering framework
     ===================================================================== */

  body.services-overview-page #engineering-framework .engineering-framework-panel {
    gap: 1.25rem !important;
    padding: clamp(1rem, 3.5vw, 1.75rem) !important;
  }

  /* --- horizontal stepper --- */
  body.services-overview-page #engineering-framework .engineering-timeline {
    position: relative;
    display: grid !important;
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    gap: 0 !important;
    width: 100%;
    min-height: 0 !important;
    padding: 0 !important;
  }
  body.services-overview-page #engineering-framework .engineering-timeline .engineering-timeline-track {
    top: 1.3125rem !important;
    bottom: auto !important;
    left: 10% !important;
    right: 10% !important;
    width: auto !important;
    height: 2px !important;
  }
  body.services-overview-page #engineering-framework .engineering-timeline .engineering-timeline-track span {
    width: var(--eng-progress, 0%) !important;
    height: 100% !important;
    background: linear-gradient(90deg, #20baff, #087ce8) !important;
    transition: width .5s cubic-bezier(.2, .7, .2, 1) !important;
  }
  body.services-overview-page #engineering-framework .engineering-timeline .engineering-step {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: .625rem !important;
    width: 100% !important;
    min-height: 0 !important;
    padding: 0 .25rem !important;
    text-align: center !important;
    -webkit-tap-highlight-color: transparent;
  }
  body.services-overview-page #engineering-framework .engineering-timeline .engineering-step:last-child { padding: 0 .25rem !important; }
  body.services-overview-page #engineering-framework .engineering-timeline .engineering-step-marker {
    width: 2.625rem !important;
    height: 2.625rem !important;
    min-width: 2.625rem !important;
    font-size: .75rem !important;
  }
  body.services-overview-page #engineering-framework .engineering-timeline .engineering-step-copy {
    width: 100% !important;
    align-items: center !important;
    padding: 0 !important;
    text-align: center !important;
  }
  body.services-overview-page #engineering-framework .engineering-timeline .engineering-step-label,
  body.services-overview-page #engineering-framework .engineering-timeline .engineering-step-description {
    display: none !important;
  }
  body.services-overview-page #engineering-framework .engineering-timeline .engineering-step-copy strong {
    font-size: .75rem !important;
    font-weight: 600 !important;
    line-height: 1.35 !important;
    color: #7d97ad !important;
    overflow-wrap: normal !important;
    text-wrap: balance;
  }
  body.services-overview-page #engineering-framework .engineering-timeline .engineering-step.is-active .engineering-step-copy strong { color: #ffffff !important; }

  /* --- visual card: image + copy side by side --- */
  body.services-overview-page #engineering-framework .engineering-visual-column { order: 0; }
  body.services-overview-page #engineering-framework .engineering-visual-card {
    display: grid !important;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr);
    grid-template-areas:
      "top  top"
      "art  copy"
      "nav  nav";
    column-gap: 1.5rem;
    align-items: stretch;
    min-height: 0 !important;
    padding: 1.125rem !important;
    border-radius: 1.25rem !important;
    transform: none !important;
  }
  body.services-overview-page #engineering-framework .engineering-card-topline { grid-area: top; margin-bottom: .75rem; }
  body.services-overview-page #engineering-framework .engineering-card-art {
    grid-area: art;
    min-height: 0 !important;
    height: auto;
    aspect-ratio: 4 / 3;
    margin: 0 !important;
    border-radius: 1rem;
  }
  body.services-overview-page #engineering-framework .engineering-card-copy {
    grid-area: copy;
    align-self: center;
    padding: 0 !important;
  }
  body.services-overview-page #engineering-framework .engineering-card-copy .engineering-card-kicker { margin: 0 0 .5rem !important; }
  body.services-overview-page #engineering-framework .engineering-card-copy .engineering-card-title {
    margin: 0 0 .625rem !important;
    font-size: clamp(1.25rem, 3vw, 1.5rem);
    line-height: 1.25 !important;
  }
  body.services-overview-page #engineering-framework .engineering-card-copy .engineering-card-description {
    font-size: .875rem !important;
    line-height: 1.75 !important;
  }

  /* --- previous / next --- */
  body.services-overview-page #engineering-framework .engineering-card-nav {
    grid-area: nav;
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-top: 1.125rem;
    padding-top: 1.125rem;
    border-top: 1px solid rgba(115, 176, 214, .18);
  }
  .engineering-nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    min-height: 2.75rem;
    border: 1px solid rgba(77, 174, 230, .38);
    border-radius: 999px;
    background: rgba(13, 38, 58, .7);
    color: #d9f1ff;
    font: 700 .75rem Inter, sans-serif;
    letter-spacing: .02em;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background .25s, border-color .25s, transform .2s;
  }
  .engineering-nav-btn:active { transform: scale(.96); }
  .engineering-nav-btn:focus-visible { outline: 2px solid #35baff; outline-offset: 2px; }
  .engineering-nav-btn svg { width: 1.125rem; height: 1.125rem; }
  .engineering-nav-prev { width: 2.75rem; padding: 0; }
  .engineering-nav-next {
    margin-left: auto;
    padding: 0 .5rem 0 1.125rem;
    border-color: rgba(33, 186, 255, .55);
    background: rgba(33, 186, 255, .12);
  }
  .engineering-nav-next b {
    display: inline-grid;
    place-items: center;
    width: 1.875rem;
    height: 1.875rem;
    border-radius: 50%;
    background: #21baff;
    color: #031321;
  }
  .engineering-nav-next b svg { width: 1rem; height: 1rem; }
  .engineering-nav-count { display: none; }
  .engineering-nav-count--unused {
    color: #8ba8bf;
    font: 800 .6875rem Inter, sans-serif;
    letter-spacing: .12em;
    font-variant-numeric: tabular-nums;
  }
  .engineering-nav-count b { color: #42c4ff; font-weight: 800; }

  /* --- phones --- */
  @media (max-width: 699px) {
    body.services-overview-page #engineering-framework .engineering-framework-panel { padding: 1rem .875rem !important; border-radius: 1.125rem !important; }
    body.services-overview-page #engineering-framework .engineering-timeline .engineering-timeline-track { top: 1.125rem !important; }
    body.services-overview-page #engineering-framework .engineering-timeline .engineering-step-marker {
      width: 2.25rem !important;
      height: 2.25rem !important;
      min-width: 2.25rem !important;
      font-size: .6875rem !important;
    }
    /* five labels cannot fit in a phone-wide row: show the active one inside the card instead */
    body.services-overview-page #engineering-framework .engineering-timeline .engineering-step-copy { display: none !important; }
    body.services-overview-page #engineering-framework .engineering-timeline .engineering-step { gap: 0 !important; }
    body.services-overview-page #engineering-framework .engineering-visual-card {
      grid-template-columns: minmax(0, 1fr);
      grid-template-areas: "top" "art" "copy" "nav";
      padding: .875rem !important;
    }
    body.services-overview-page #engineering-framework .engineering-card-art { aspect-ratio: 16 / 10; }
    body.services-overview-page #engineering-framework .engineering-card-copy { margin-top: 1rem; align-self: start; }
    body.services-overview-page #engineering-framework .engineering-card-copy .engineering-card-title { font-size: 1.1875rem; }
    body.services-overview-page #engineering-framework .engineering-card-copy .engineering-card-description { font-size: .8125rem !important; line-height: 1.7 !important; }
  }

  /* --- light theme --- */
  html[data-theme="light"] body.services-overview-page #engineering-framework .engineering-timeline .engineering-step-copy strong { color: #5b7790 !important; }
  html[data-theme="light"] body.services-overview-page #engineering-framework .engineering-timeline .engineering-step.is-active .engineering-step-copy strong { color: #0a4f7d !important; }
  html[data-theme="light"] body.services-overview-page #engineering-framework .engineering-card-nav { border-top-color: rgba(0, 105, 190, .16); }
  html[data-theme="light"] .engineering-nav-btn { background: #ffffff; color: #123451; border-color: rgba(0, 105, 190, .25); }
  html[data-theme="light"] .engineering-nav-next { background: rgba(8, 127, 192, .1); border-color: rgba(8, 127, 192, .5); }
  html[data-theme="light"] .engineering-nav-next b { background: #087fc0; color: #fff; }
  html[data-theme="light"] .engineering-nav-count { color: #365b76; }
  html[data-theme="light"] .engineering-nav-count b { color: #087fc0; }
}

@media (prefers-reduced-motion: reduce) {
  #process .timeline-topline::after,
  #process .timeline-point,
  .engineering-nav-btn { transition: none !important; }
}
