/* ==========================================================================
   Markets page (/markets, /fr/marches)
   Loaded only on this page, AFTER /css/style.css (shared styles, colours,
   motion system). Rules used on more than one page belong in style.css.
   Motion only under .js-motion (JS on, no reduced-motion preference):
   without it every route is drawn, nothing moves and nothing is hidden.
   ========================================================================== */

/* ---- Hero ----------------------------------------------------------------- */
.page-hero--markets h1 { max-width: 16ch; }

/* ---- Route map ------------------------------------------------------------ */
.route-map-section .section-head { margin-bottom: 1.75rem; }
.route-map { margin: 0; }
/* The viewport shows one crop of the full map (custom properties from
   lib/world-map.js → frameStyle: --m-* phones, --d-* from 900 px).
   Crop: East Asia (left) → North America → Europe (right).
   Phones / small tablets: a 1100 px-wide map inside a frame that scrolls
   sideways; main.js starts it scrolled so the origin is in view. */
.route-map-frame {
  position: relative; overflow-x: auto; overflow-y: hidden;
  border-radius: 20px;
  background: radial-gradient(120% 90% at 30% 40%, #2c2723 0%, #221e1b 60%, #1a1715 100%);
  box-shadow: inset 0 0 0 1px var(--line-light);
  scrollbar-width: thin; scrollbar-color: rgba(250, 247, 242, 0.3) transparent;
  -webkit-overflow-scrolling: touch;
}
.route-map-frame:focus-visible { outline: 3px solid var(--ember); outline-offset: 3px; }
.route-map-viewport { position: relative; overflow: hidden; width: 1100px; aspect-ratio: var(--m-ratio); }
/* "‹ Pacific · Swipe the map · Atlantic ›" (phones only) */
.route-map-hint { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin: 0.5rem 0 0; font-size: 0.8rem; color: var(--muted-light); }
.route-map-hint > span { display: inline-flex; align-items: center; gap: 0.2rem; }
.route-map-hint-mid { opacity: 0.75; }
.route-map-canvas {
  position: absolute;
  width: var(--m-w); height: var(--m-h); left: var(--m-left); top: var(--m-top);
  /* Sizes in map units, tuned per breakpoint (1 unit ≈ 1.45 px on phones, ≈ 1.6 px on a 1200 px desktop) */
  --route-w: 1.6; --route-dash: 3.2 2.6; --glow-w: 5;
}
.route-map-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.route-map-land { opacity: 0.3; }

/* Routes: the mask path reveals the visible line (works for dashed lines too) */
.map-route-reveal { fill: none; stroke: #fff; stroke-width: 12; stroke-linecap: round; stroke-dasharray: 1 1; stroke-dashoffset: 0; }
.map-route-line { fill: none; stroke: var(--ember); stroke-width: var(--route-w); stroke-linecap: round; transition: stroke-width 0.25s ease, opacity 0.25s ease; }
.map-route--road .map-route-line, .map-route-line.map-route-feeder { stroke-dasharray: var(--route-dash); stroke: #f3a76f; }
.map-route-glow { fill: none; stroke: var(--ember); stroke-width: var(--glow-w); stroke-linecap: round; opacity: 0; transition: opacity 0.25s ease; }
.map-route { transition: opacity 0.25s ease; }
.map-ship { fill: var(--off-white); stroke: var(--ember); stroke-width: 0.8; opacity: 0; }

/* Draw-in when the map scrolls into view (main.js adds .is-revealed) */
.js-motion .route-map:not(.is-revealed) .map-route-reveal { stroke-dashoffset: 1; }
.js-motion .map-route-reveal { transition: stroke-dashoffset 1.6s var(--ease-out); }
.js-motion .map-route:nth-of-type(2) .map-route-reveal { transition-delay: 0.15s; }
.js-motion .map-route:nth-of-type(3) .map-route-reveal { transition-delay: 0.3s; }
.js-motion .map-route:nth-of-type(4) .map-route-reveal { transition-delay: 0.45s; }
.js-motion .map-route:nth-of-type(5) .map-route-reveal { transition-delay: 0.6s; }
.js-motion .map-route:nth-of-type(6) .map-route-reveal { transition-delay: 0.75s; }
.js-motion .map-route:nth-of-type(n+7) .map-route-reveal { transition-delay: 0.9s; }
.js-motion .route-map.is-sailing .map-ship { opacity: 1; transition: opacity 0.4s ease; }

/* Highlight: hovering / focusing a card or a pin (main.js sets .has-active + .is-active) */
.route-map.has-active .map-route:not(.is-active) { opacity: 0.28; }
.route-map .map-route.is-active .map-route-line { stroke-width: calc(var(--route-w) * 1.6); }
.route-map .map-route.is-active .map-route-glow { opacity: 0.28; }

/* Origin (the yard) — soft pulse */
.map-origin, .map-pin { position: absolute; width: 0; height: 0; }
.map-origin-dot {
  position: absolute; left: -7px; top: -7px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--ember); box-shadow: 0 0 0 3px rgba(232, 116, 42, 0.35);
}
.js-motion .map-origin-dot::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid var(--ember); animation: map-pulse 2.4s ease-out infinite;
}
@keyframes map-pulse {
  from { transform: scale(1); opacity: 0.8; }
  to { transform: scale(3.2); opacity: 0; }
}
.map-origin-label, .map-pin-label {
  position: absolute; display: inline-flex; align-items: center; gap: 0.35rem; white-space: nowrap;
  padding: 0.2rem 0.55rem; border-radius: 999px;
  font-size: 0.72rem; font-weight: 600; line-height: 1.3;
}
.map-origin-label { left: 50%; bottom: 12px; transform: translateX(-50%); background: var(--ember); color: var(--charcoal); }
.map-origin-label .icon { width: 13px; height: 13px; }

/* Departure ports (where the sea legs start) */
.map-port { position: absolute; width: 0; height: 0; }
.map-port-dot {
  position: absolute; left: -5px; top: -5px; width: 10px; height: 10px; border-radius: 3px;
  background: var(--charcoal); border: 2px solid #f3a76f; transform: rotate(45deg);
}
.map-port-label {
  position: absolute; left: 0; top: 9px; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 0.25rem; white-space: nowrap;
  padding: 0.1rem 0.4rem; border-radius: 6px;
  font-size: 0.66rem; font-weight: 600; line-height: 1.3;
  background: rgba(30, 27, 24, 0.82); color: var(--off-white); box-shadow: inset 0 0 0 1px var(--line-light);
}
.map-port-label .icon { width: 11px; height: 11px; color: #f3a76f; }

/* Destination pins (links to the market cards) */
.map-pin-link { position: absolute; left: 0; top: 0; color: var(--charcoal); text-decoration: none; }
.map-pin-dot {
  position: absolute; left: -6px; top: -6px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--off-white); border: 3px solid var(--ember);
  transition: transform 0.2s ease;
}
.map-pin-label { background: var(--off-white); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35); transition: background-color 0.2s ease, color 0.2s ease; }
.map-pin-flag { flex: none; width: 16px; height: 12px; border-radius: 2px; background-size: cover; background-position: center; box-shadow: 0 0 0 1px var(--line); }
.map-pin--right .map-pin-label { left: 11px; top: 0; transform: translateY(-50%); }
.map-pin--left .map-pin-label { right: 11px; top: 0; transform: translateY(-50%); }
.map-pin--above .map-pin-label { left: 0; bottom: 11px; transform: translateX(-50%); }
.map-pin--below .map-pin-label { left: 0; top: 11px; transform: translateX(-50%); }
.map-pin.is-active .map-pin-label, .map-pin-link:hover .map-pin-label, .map-pin-link:focus-visible .map-pin-label { background: var(--ember); color: var(--charcoal); }
.map-pin.is-active .map-pin-dot, .map-pin-link:hover .map-pin-dot { transform: scale(1.3); }
.map-pin-link:focus-visible { outline: none; }
.map-pin-link:focus-visible .map-pin-label { outline: 3px solid var(--off-white); outline-offset: 2px; }

.route-map-legend {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1.4rem;
  margin-top: 1rem; font-size: 0.88rem; color: var(--muted-light);
}
.legend-item { display: inline-flex; align-items: center; gap: 0.5rem; }
.legend-swatch { display: inline-block; width: 28px; height: 0; border-top: 3px solid var(--ember); }
.legend-swatch--road, .legend-swatch--feeder { border-top: 3px dashed #f3a76f; }
.legend-swatch--feeder { width: 16px; }
.legend-swatch--port { width: 10px; height: 10px; border: 2px solid #f3a76f; border-radius: 2px; background: var(--charcoal); transform: rotate(45deg); }
.legend-swatch--origin { width: 12px; height: 12px; border: 0; border-radius: 50%; background: var(--ember); }
.legend-note { flex-basis: 100%; font-size: 0.82rem; }
.section--dark .legend-note a { color: var(--muted-light); text-decoration: underline; }

/* ---- Market cards: groups by region, 2 per row from 768 px ----------------- */
.flag--lg { width: 56px; height: 42px; border-radius: 8px; }
.flag--globe { background: var(--charcoal); color: var(--ember); }
.market-group + .market-group { margin-top: 2.75rem; }
.market-group-title {
  display: flex; align-items: center; gap: 0.6rem;
  margin: 0 0 1.1rem; padding-bottom: 0.6rem; border-bottom: 1px solid var(--line);
  font-size: 1.15rem; letter-spacing: 0.01em;
}
.market-group-icon { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 10px; background: var(--charcoal); color: var(--ember); flex: none; }
.market-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 1.5rem; align-items: stretch; }
.market-panel {
  display: flex; flex-direction: column; gap: 1.1rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 22px;
  padding: 1.5rem;
  scroll-margin-top: calc(var(--header-h) + 2rem);
  transition: transform 0.3s var(--ease-out), box-shadow 0.3s var(--ease-out), border-color 0.2s ease;
}
.market-panel:hover, .market-panel.is-active { transform: translateY(-4px); box-shadow: var(--shadow-lift); border-color: rgba(232, 116, 42, 0.45); }
.market-panel:target { border-color: var(--ember); box-shadow: 0 0 0 3px rgba(232, 116, 42, 0.25); }
.market-panel p { color: var(--muted); margin: 0; }
.market-panel-head { display: flex; align-items: center; gap: 1rem; }
.market-panel-title { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.75rem; }
.market-panel-name { margin: 0; font-size: 1.45rem; }
.market-panel .market-panel-note { color: var(--charcoal); font-weight: 600; }
.market-mode-badge--sea { background: #e6eef2; color: #24495a; }

/* Mini route: "Canada ●──── ship ────● Japan" + departure port / transit */
.mini-route { background: var(--beige-soft); border-radius: 14px; padding: 0.85rem 1rem; }
.market-panel .mini-route-line { display: flex; align-items: center; gap: 0.6rem; font-size: 0.82rem; font-weight: 700; color: var(--charcoal); }
.mini-route-end { flex: none; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-route-track { position: relative; flex: 1; height: 28px; min-width: 70px; }
.mini-route-stop { position: absolute; top: 50%; width: 10px; height: 10px; margin-top: -5px; border-radius: 50%; background: var(--ember); }
.mini-route-stop--start { left: 0; }
.mini-route-stop--end { right: 0; background: var(--surface); border: 2px solid var(--ember); }
.mini-route-path { position: absolute; left: 6px; right: 6px; top: 50%; margin-top: -1px; border-top: 2px solid var(--ember); transform-origin: left center; }
.mini-route--truck .mini-route-path { border-top-style: dashed; border-color: #d9824a; }
.mini-route-icon {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--surface); color: var(--ember-text); box-shadow: 0 0 0 2px var(--beige-soft), 0 0 0 3px rgba(232, 116, 42, 0.35);
}
.mini-route-meta { list-style: none; margin: 0.6rem 0 0; padding: 0; display: grid; gap: 0.25rem; font-size: 0.86rem; color: var(--charcoal-80); }
.mini-route-meta li { display: flex; align-items: flex-start; gap: 0.45rem; }
.mini-route-meta .icon { flex: none; margin-top: 0.22rem; color: var(--ember-text); }
.market-panel.is-active .mini-route-icon { background: var(--ember); color: var(--charcoal); }
/* Draws in when the card appears (JS on, motion allowed); otherwise drawn */
.js-motion .mini-route-path { transition: transform 0.9s var(--ease-out) 0.35s; }
.js-motion .mini-route-icon, .js-motion .mini-route-stop--end { transition: opacity 0.4s ease 0.9s, transform 0.4s var(--ease-out) 0.9s; }
.js-motion .market-panel:not(.is-revealed) .mini-route-path { transform: scaleX(0); }
.js-motion .market-panel:not(.is-revealed) .mini-route-icon { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
.js-motion .market-panel:not(.is-revealed) .mini-route-stop--end { opacity: 0; }

/* Body: highlights + terms | ports + documents (2 columns from 1024 px) */
.market-panel-body { display: grid; gap: 1.1rem; }
.market-panel-col { display: grid; gap: 1rem; align-content: start; }
.tick-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.45rem; font-size: 0.95rem; }
.tick-list li { display: flex; gap: 0.5rem; align-items: flex-start; }
.tick-list .icon { flex: none; margin-top: 0.2rem; color: var(--ember-text); }
.market-panel-label { display: flex; align-items: center; gap: 0.4rem; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; margin: 0 0 0.5rem; }
.market-panel-label .icon { color: var(--ember-text); }
.market-panel .market-panel-label { color: var(--charcoal); margin-bottom: 0.5rem; }
.market-panel .tag-list { margin: 0; }
.doc-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35rem; font-size: 0.88rem; color: var(--charcoal-80); }
.doc-list li { display: flex; align-items: flex-start; gap: 0.5rem; }
.doc-list .icon { flex: none; margin-top: 0.15rem; color: var(--ember-text); }
.market-panel .market-panel-flag { display: flex; gap: 0.4rem; align-items: flex-start; font-size: 0.82rem; font-style: italic; }
.market-panel-flag .icon { flex: none; margin-top: 0.2rem; color: var(--ember-text); }

/* Footer: full-width estimate CTA + WhatsApp link */
.market-panel-foot { margin-top: auto; padding-top: 1.1rem; border-top: 1px solid var(--line); display: grid; gap: 0.6rem; justify-items: center; }
.market-panel-cta { width: 100%; justify-content: center; }
.market-panel-wa { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.88rem; font-weight: 600; color: var(--ember-text); }
.market-panel-wa:hover { color: var(--charcoal); }

.term-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.term-chip {
  display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.25rem 0.7rem; border-radius: 999px;
  font-size: 0.85rem; font-weight: 700; letter-spacing: 0.04em; text-decoration: none;
  background: var(--charcoal); color: var(--off-white);
  transition: background-color 0.2s ease, color 0.2s ease;
}
a.term-chip:hover, a.term-chip:focus-visible { background: var(--ember); color: var(--charcoal); }
.term-chip--light { background: var(--surface); color: var(--charcoal); box-shadow: inset 0 0 0 1px var(--line); }
.term-chip--plain { background: transparent; color: var(--muted); font-weight: 500; letter-spacing: 0; box-shadow: inset 0 0 0 1px var(--line); }

/* "Other markets" band */
.market-band {
  display: grid; gap: 1.25rem; align-items: center; margin-top: 1.5rem;
  background: var(--charcoal); color: var(--off-white); border-radius: 20px; padding: 1.75rem;
  scroll-margin-top: calc(var(--header-h) + 2rem);
  position: relative; overflow: hidden; isolation: isolate;
}
.market-band::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: radial-gradient(60% 120% at 0% 50%, rgba(232, 116, 42, 0.22), transparent 70%);
}
.market-band:target { box-shadow: 0 0 0 3px rgba(232, 116, 42, 0.5); }
.market-band h3 { color: var(--off-white); margin-bottom: 0.25rem; }
.market-band p { margin: 0 0 0.5rem; color: var(--muted-light); }
.market-band .eyebrow { color: var(--ember); margin-bottom: 0.3rem; }
.market-band .market-panel-note { color: var(--off-white); font-weight: 600; }
.market-band .term-chips { margin-top: 0.75rem; }
.market-band .term-chip--light { background: rgba(250, 247, 242, 0.1); color: var(--off-white); box-shadow: inset 0 0 0 1px var(--line-light); }
.market-band .term-chip--plain { color: var(--muted-light); box-shadow: inset 0 0 0 1px var(--line-light); }
.market-band-globe { position: relative; width: 110px; height: 110px; }
.globe-art { width: 100%; height: 100%; fill: none; stroke: rgba(250, 247, 242, 0.35); stroke-width: 1.4; }
.globe-orbit { stroke: var(--ember); stroke-width: 2; stroke-dasharray: 4 5; }
.js-motion .globe-orbit { animation: globe-orbit 6s linear infinite; }
@keyframes globe-orbit { to { stroke-dashoffset: -90; } }
.market-band-globe .flag { position: absolute; right: -4px; bottom: 4px; }
.market-band-cta { justify-self: start; }

/* ---- Road or sea? ---------------------------------------------------------- */
.compare { display: grid; gap: 1.25rem; }
.compare-col { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 1.5rem; }
.compare-head { display: flex; align-items: center; gap: 0.9rem; margin-bottom: 1rem; }
.compare-head h3 { margin: 0; }
.compare-icon { display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px; border-radius: 14px; background: var(--charcoal); color: var(--ember); flex: none; }
.compare-tag { font-size: 0.85rem; color: var(--muted); }
.compare-facts { margin: 0; display: grid; gap: 0.9rem; }
.compare-facts dt { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin-bottom: 0.15rem; }
.compare-facts dd { margin: 0; }
.compare-figure { font-family: var(--font-display); font-size: 1.6rem; font-weight: 600; color: var(--charcoal); }
.compare-line { display: block; }

/* ---- Canadian ports strip -------------------------------------------------- */
.ports-strip { display: grid; gap: 1.25rem; align-items: center; }
.ports-strip-head p { margin: 0; color: var(--muted); }
.ports-strip-head h2 { margin-bottom: 0.35rem; }
.ports-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; }
.port-item {
  display: flex; align-items: center; gap: 0.75rem; padding: 0.85rem 1rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
}
.port-icon { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; background: var(--beige-soft); color: var(--ember-text); flex: none; }
.port-name { font-weight: 600; }
.port-province { margin-left: auto; font-size: 0.8rem; font-weight: 700; color: var(--muted); background: var(--beige-soft); border-radius: 6px; padding: 0.1rem 0.45rem; }

/* ==========================================================================
   Breakpoints (mobile-first)
   ========================================================================== */
@media (max-width: 599px) {
  .map-pin-label, .map-origin-label { font-size: 0.66rem; padding: 0.15rem 0.45rem; gap: 0.25rem; }
  .map-pin-flag { width: 13px; height: 10px; }
  .map-origin-dot { left: -5px; top: -5px; width: 10px; height: 10px; }
  .map-pin-dot { left: -5px; top: -5px; width: 10px; height: 10px; border-width: 2px; }
  .map-port-label { font-size: 0.6rem; }
  .route-map-frame { border-radius: 14px; }
}
@media (min-width: 600px) {
  .market-band { grid-template-columns: auto 1fr; gap: 1.75rem; }
  .market-band-cta { grid-column: 2; }
  .ports-list { grid-template-columns: repeat(3, 1fr); }
  .compare { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 768px) {
  .market-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 900px) {
  .route-map-frame { overflow: hidden; }
  .route-map-viewport { width: 100%; aspect-ratio: var(--d-ratio); }
  .route-map-hint { display: none; }
  .route-map-canvas {
    width: var(--d-w); height: var(--d-h); left: var(--d-left); top: var(--d-top);
    --route-w: 1.3; --route-dash: 2.8 2.2; --glow-w: 4.5;
  }
  .map-ship { r: 2.2px; }
  .market-band { grid-template-columns: auto 1fr auto; }
  .market-band-cta { grid-column: auto; justify-self: end; }
  .ports-strip { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 2.5rem; }
  .compare-col { padding: 2rem; }
}
@media (min-width: 1024px) {
  .market-panel { padding: 2rem; }
  .market-panel-body { grid-template-columns: 1fr 1fr; gap: 1.5rem; }
}
