/* ==================================================================
   ARAFA CNC — MACHINE DETAILS
   01 Breadcrumb  02 Main product  03 Photo gallery
   04 Name / description / actions  05 Specifications
   06 Compact video  07 Related machines (last section)
   08 Responsive + accessibility
   Visual style matches the approved Spare Part Details page.
================================================================== */
.machine-page {
  --machine-orange: #ff5a12;
  --machine-orange-dark: #e54c06;
  --machine-navy: #061725;
  --machine-muted: #617080;
  --machine-surface: #f1f1f1;
  width: 100%; min-width: 0;
  font-family: 'Cairo', sans-serif;
}
.machine-page *, .machine-page *::before, .machine-page *::after { box-sizing: border-box; }
.machine-page .container { width: min(100%, 1300px); margin: 0 auto; padding-inline: 22px; }
.machine-page [hidden] { display: none !important; }
.machine-page a { text-decoration: none; }
.machine-page img { max-width: 100%; }

/* =================== SECTION 01 — BREADCRUMB =================== */
.machine-breadcrumb { background: var(--machine-surface); padding-top: 23px; }
.machine-breadcrumb__inner { display: flex; align-items: center; justify-content: flex-start; gap: 9px; flex-wrap: wrap; color: #637487; font-size: 13px; }
.machine-breadcrumb a { color: var(--machine-navy); }
.machine-breadcrumb a:hover { color: var(--machine-orange); }
.machine-breadcrumb [data-breadcrumb-product] { color: var(--machine-orange); font-weight: 700; }

/* =================== SECTION 02 — MAIN PRODUCT =================== */
.machine-details-section { background: var(--machine-surface); padding: 42px 0 64px; }
.machine-details-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: clamp(32px, 5vw, 82px); }
.machine-gallery, .machine-info { min-width: 0; }

/* =================== SECTION 03 — DYNAMIC IMAGE GALLERY =================== */
.machine-gallery { width: 100%; }
.machine-main-media { position: relative; width: 100%; height: clamp(325px, 32vw, 430px); padding: 8px 52px; display: grid; place-items: center; overflow: hidden; }
.machine-main-media > img { width: 100%; height: 100%; object-fit: contain; object-position: center; display: block; }
.machine-image-empty { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: #8694a0; font-size: 13px; }
.machine-image-empty i { font-size: 48px; }
.machine-arrow { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; display: grid; place-items: center; width: 42px; height: 42px; padding: 0; border: 0; border-radius: 50%; color: #fff; background: var(--machine-orange); cursor: pointer; transition: background .2s; }
.machine-arrow:hover { background: var(--machine-orange-dark); }
.machine-arrow--previous { inset-inline-start: 4px; }
.machine-arrow--next { inset-inline-end: 4px; }
.machine-thumbs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 10px; padding: 0 52px; }
.machine-thumb { display: grid; place-items: center; min-width: 0; width: 100%; height: 78px; padding: 5px; background: #fff; border: 2px solid transparent; border-radius: 6px; overflow: hidden; cursor: pointer; transition: border-color .2s; }
.machine-thumb img { display: block; width: 100%; height: 100%; object-fit: contain; }
.machine-thumb.is-active { border-color: var(--machine-orange); }
.machine-thumb.has-missing-image img { visibility: hidden; }

/* =================== SECTION 04 — INFORMATION & CTA =================== */
.machine-info { padding-block: 10px; text-align: start; }
.machine-category { display: inline-block; margin-bottom: 8px; color: var(--machine-orange); font-size: 12px; font-weight: 800; }
.machine-info h1 { position: relative; width: fit-content; max-width: 100%; margin: 0 0 19px; padding-bottom: 12px; color: var(--machine-navy); font-size: clamp(28px, 2.8vw, 36px); font-weight: 800; line-height: 1.4; overflow-wrap: anywhere; }
.machine-info h1::after { content: ''; position: absolute; inset-inline-start: 0; bottom: 0; width: 75px; height: 2px; background: var(--machine-orange); }
.machine-description { max-width: 650px; color: #536779; font-size: 14px; line-height: 1.95; overflow-wrap: anywhere; }
.machine-description p { margin: 0 0 12px; }
.machine-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 28px; }
.machine-btn { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; min-width: 138px; padding: 10px 18px; border: 1px solid transparent; border-radius: 6px; font-size: 12px; font-weight: 800; line-height: 1.6; text-align: center; transition: background .2s, color .2s; }
.machine-btn--primary { background: var(--machine-orange); border-color: var(--machine-orange); color: #fff !important; }
.machine-btn--primary:hover { background: var(--machine-orange-dark); border-color: var(--machine-orange-dark); }
.machine-btn--outline { background: transparent; border-color: var(--machine-navy); color: var(--machine-navy) !important; }
.machine-btn--outline:hover { background: var(--machine-navy); color: #fff !important; }

/* =================== SECTION 05 — COMPACT TECHNICAL SPECIFICATIONS =================== */
.machine-specifications-section { background: var(--machine-surface); padding: 18px 0 44px; }
.machine-specifications-layout { display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; gap: 17px; max-width: 1050px; }
.machine-specifications-heading, .machine-specifications-content { min-width: 0; }
.machine-specifications-heading h2, .machine-related-section h2, .machine-video-heading h2 { margin: 0; color: #0b2440; font-size: clamp(25px, 2.5vw, 33px); font-weight: 800; line-height: 1.4; }
.machine-spec-table-wrap { width: 100%; max-width: 100%; border: 1px solid #dedede; border-radius: 8px; overflow: hidden; }
.machine-spec-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 13px; line-height: 1.55; }
.machine-spec-table tr:nth-child(odd) { background: #f5f5f5; }
.machine-spec-table tr:nth-child(even) { background: #fff; }
.machine-spec-table td { text-align: start; padding: 7px 12px; border-bottom: 1px solid #dedede; border-inline-end: 1px solid #dedede; color: #10293d; vertical-align: middle; overflow-wrap: anywhere; }
.machine-spec-table tr:last-child td { border-bottom: 0; }
.machine-spec-table td:first-child { width: 34%; font-weight: 700; }
.machine-spec-table td:last-child { border-inline-end: 0; }
.machine-spec-table .machine-spec-empty { color: var(--machine-muted); font-weight: 400; text-align: center; }

/* =================== SECTION 07 — RELATED MACHINES (FINAL) =================== */
.machine-related-section { padding: 45px 0 65px; background: #fff; }
.machine-related-section h2 { margin-bottom: 24px; }
.machine-related-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.machine-related-card { min-width: 0; padding: 13px; display: block; background: #fff; border: 1px solid #e1e8ee; border-radius: 12px; transition: border-color .2s, transform .2s; }
.machine-related-card:hover { border-color: var(--machine-orange); transform: translateY(-2px); }
.machine-related-card__media { height: 170px; display: grid; place-items: center; margin-bottom: 12px; overflow: hidden; }
.machine-related-card__media img { width: 100%; height: 100%; object-fit: contain; }
.machine-related-card__media.is-missing img { display: none; }
.machine-related-card h3 { color: var(--machine-navy); font-size: 15px; line-height: 1.7; margin: 0; text-align: start; }

/* =================== SECTION 06 — COMPACT VIDEO BEFORE RELATED =================== */
.machine-video-section { background: var(--machine-surface); padding: 25px 0 50px; scroll-margin-top: 95px; }
.machine-video-heading { text-align: center; margin-bottom: 15px; }
.machine-video-kicker { display: block; margin-bottom: 5px; color: var(--machine-orange); font-size: 12px; font-weight: 800; letter-spacing: .06em; }
.machine-video-heading p { margin: 6px 0 0; color: var(--machine-muted); font-size: 13px; }
.machine-video-stage { position: relative; width: min(100%, 720px); aspect-ratio: 16 / 9; margin: 0 auto; border: 1px solid #e2e7ec; border-radius: 12px; background: #fff; overflow: hidden; }
/* Keep the empty state short; real YouTube/MP4 players retain a full 16:9 frame. */
.machine-video-stage:has(> .machine-video-empty) { aspect-ratio: auto; }
.machine-video-stage > iframe, .machine-video-stage > video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #071725; }
.machine-video-stage > video { object-fit: contain; }
.machine-video-empty { display: flex; min-height: 165px; height: 100%; width: 100%; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: #7b8c9d; text-align: center; padding: 18px; }
.machine-video-empty i { font-size: 38px; color: var(--machine-orange); }
.machine-video-empty p { margin: 0; line-height: 1.8; font-weight: 600; }
.machine-not-found { padding: 80px 0; text-align: center; background: var(--machine-surface); }
.machine-not-found h1 { color: var(--machine-navy); }
.machine-not-found a { color: var(--machine-orange); }

/* =================== SECTION 08 — RESPONSIVE =================== */
@media (max-width: 980px) {
  .machine-details-top { gap: 26px; }
  .machine-actions { gap: 8px; }
  .machine-btn { min-width: 122px; }
}
@media (max-width: 900px) {
  .machine-details-top { grid-template-columns: minmax(0, 1fr); gap: 26px; }
  .machine-gallery { max-width: 720px; margin-inline: auto; }
  .machine-main-media { height: 400px; }
  .machine-info { padding: 0; }
  .machine-specifications-layout { grid-template-columns: minmax(0, 1fr); }
  .machine-related-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .machine-page .container { padding-inline: 16px; }
  .machine-breadcrumb { padding-top: 16px; }
  .machine-breadcrumb__inner { font-size: 11px; gap: 6px; }
  .machine-details-section { padding: 17px 0 35px; }
  .machine-main-media { height: 290px; padding: 8px 43px; }
  .machine-arrow { width: 35px; height: 35px; }
  .machine-arrow--previous { inset-inline-start: 0; }
  .machine-arrow--next { inset-inline-end: 0; }
  .machine-thumbs { padding: 0; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
  .machine-thumb { height: 67px; padding: 3px; }
  .machine-info h1 { font-size: 27px; }
  .machine-description { font-size: 13px; }
  .machine-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .machine-btn { width: 100%; min-width: 0; padding: 10px 8px; }
  .machine-btn:first-child { grid-column: 1 / -1; }
  .machine-specifications-section { padding: 15px 0 30px; }
  .machine-specifications-heading h2, .machine-related-section h2, .machine-video-heading h2 { font-size: 27px; }
  .machine-spec-table { font-size: 12px; }
  .machine-spec-table td { padding: 8px 9px; }
  .machine-related-grid { grid-template-columns: minmax(0, 1fr); gap: 13px; }
  .machine-related-card__media { height: 190px; }
  .machine-related-section { padding: 36px 0 48px; }
  .machine-video-section { padding: 25px 0 36px; }
  .machine-video-stage { border-radius: 9px; }
  .machine-video-empty { min-height: 145px; padding: 12px; }
  .machine-video-empty i { font-size: 34px; }
  .machine-video-empty p { font-size: 12px; }
  .machine-video-heading { margin-bottom: 12px; }
}
.machine-page :is(.machine-arrow, .machine-thumb, .machine-btn, .machine-related-card):focus-visible { outline: 3px solid var(--machine-orange); outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) {
  .machine-page :is(.machine-arrow, .machine-thumb, .machine-btn, .machine-related-card) { transition: none; }
}
