/* TankerEX — Swiss typographic hub + animated scene */

:root {
  --bg: #fafafa;
  --ink: #111827;
  --ink-muted: #4b5563;
  --ink-faint: #6b7280;
  --line: #d1d5db;
  --accent: #0861c5;
  --accent-hit: #1ea9ff;
  --scene-stroke: #cbd5e1;
  --scene-fill: #ffffff;
  --scene-muted: #e2e8f0;
  --scene-ink: #334155;
  --scene-accent: #0861c5;
  --scene-live: #1ea9ff;
  --font-display: "Outfit", "Noto Sans TC", sans-serif;
  --font-body: "Noto Sans TC", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --pad: clamp(1rem, 4vw, 3rem);
  --pad-x: clamp(1rem, 4vw, 3rem);
  --max: 72rem;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

.dark {
  --bg: #111318;
  --ink: #f3f4f6;
  --ink-muted: #9ca3af;
  --ink-faint: #6b7280;
  --line: #2d3340;
  --accent: #1ea9ff;
  --accent-hit: #83dbff;
  --scene-stroke: #3d4654;
  --scene-fill: #1a1d24;
  --scene-muted: #252a33;
  --scene-ink: #94a3b8;
  --scene-accent: #1ea9ff;
  --scene-live: #83dbff;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  overflow-x: clip;
}

body {
  min-height: 100dvh;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  overflow-x: clip;
}

a {
  color: inherit;
  text-decoration: none;
}

.hub {
  position: relative;
  display: flex;
  min-height: 100dvh;
  flex-direction: column;
  padding:
    calc(var(--pad) + env(safe-area-inset-top, 0px))
    var(--pad-x)
    0;
}

.hub__grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
}

.dark .hub__grain {
  opacity: 0.2;
}

.hub__head,
.hub__main,
.hub__foot {
  position: relative;
  z-index: 1;
}

/* ── Header ── */

.hub__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  max-width: var(--max);
  width: 100%;
  margin: 0 auto clamp(0.75rem, 3vh, 2.5rem);
}

@media (max-width: 899px) {
  .hub__title {
    font-size: clamp(1.85rem, 8.5vw, 2.5rem);
  }

  .hub__note {
    max-width: none;
  }

  .hub__main {
    padding-bottom: 1.25rem;
  }
}

@media (max-width: 479px) {
  .hub__theme-text {
    display: none;
  }

  .hub__theme {
    padding: 0.5rem;
  }

  .hub__mark-full {
    display: none;
  }
}

@media (min-width: 480px) {
  .hub__mark-short {
    display: none;
  }
}

.hub__mark {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  font-family: var(--font-display);
  font-size: clamp(0.72rem, 2.5vw, 0.8rem);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hub__mark span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hub__mark img {
  width: 1.375rem;
  height: 1.375rem;
}

.hub__theme {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--scene-fill);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 1px 2px color-mix(in srgb, var(--ink) 6%, transparent);
  transition:
    color 0.2s var(--ease),
    border-color 0.2s var(--ease),
    background 0.2s var(--ease),
    transform 0.15s var(--ease);
}

.hub__theme:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.hub__theme:active {
  transform: scale(0.97);
}

.hub__theme:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.hub__theme-icon {
  position: relative;
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.hub__theme-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
}

.hub__theme-svg--sun {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

.hub__theme-svg--moon {
  opacity: 0;
  transform: rotate(-30deg) scale(0.8);
}

.dark .hub__theme-svg--sun {
  opacity: 0;
  transform: rotate(30deg) scale(0.8);
}

.dark .hub__theme-svg--moon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* ── Main grid ── */

.hub__main {
  flex: 1;
  display: flex;
  align-items: flex-start;
  max-width: var(--max);
  width: 100%;
  margin: 0 auto;
  padding-bottom: clamp(1.5rem, 5vh, 4rem);
}

@media (min-width: 768px) {
  .hub__main {
    align-items: center;
  }
}

.hub__grid {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas:
    "intro"
    "nav"
    "scene";
  gap: clamp(1rem, 3.5vw, 1.75rem);
  width: 100%;
  align-items: start;
}

.hub__intro {
  grid-area: intro;
  margin-bottom: 0;
  animation: fade-up 0.6s var(--ease) both;
}

.hub__scene {
  grid-area: scene;
}

.hub__nav {
  grid-area: nav;
  display: flex;
  flex-direction: column;
  border-top: 2px solid var(--ink);
}

@media (min-width: 900px) {
  .hub__grid {
    grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
    grid-template-areas:
      "intro scene"
      "nav scene";
    gap: clamp(1.25rem, 2.5vw, 2rem) clamp(1.5rem, 2.5vw, 2.75rem);
    align-items: start;
  }
}

@media (min-width: 1200px) {
  .hub__grid {
    grid-template-columns: minmax(0, 0.88fr) minmax(0, 1.12fr);
    gap: clamp(1.5rem, 2vw, 2rem) clamp(2rem, 3vw, 3.5rem);
  }
}

.hub__kicker {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.hub__title {
  margin-top: 0.6rem;
  font-family: var(--font-display);
  font-size: clamp(2rem, 9vw, 4rem);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.hub__note {
  max-width: 32ch;
  margin-top: 1rem;
  font-size: clamp(0.88rem, 2.5vw, 0.95rem);
  line-height: 1.65;
  color: var(--ink-muted);
}

/* ── Navigation ── */

.hub__link {
  display: block;
  padding: clamp(1rem, 3vw, 1.35rem) 0;
  border-bottom: 1px solid var(--line);
  transition:
    padding-left 0.22s var(--ease),
    background 0.22s var(--ease);
  animation: fade-up 0.6s var(--ease) both;
}

@media (min-width: 768px) and (max-width: 899px) {
  .hub__title {
    font-size: clamp(2rem, 5vw, 2.75rem);
  }

  .hub__note {
    max-width: 40ch;
  }
}

@media (min-width: 900px) and (max-width: 1100px) {
  .hub__title {
    font-size: clamp(1.85rem, 3.2vw, 2.35rem);
  }

  .hub__link-role {
    font-size: clamp(1.2rem, 2.2vw, 1.55rem);
  }

  .hub__intro {
    margin-bottom: 1.25rem;
  }

  .hub__link {
    padding: 0.85rem 0;
  }

  .hub__link-desc {
    font-size: 0.82rem;
  }
}

.hub__link:nth-child(1) {
  animation-delay: 0.08s;
}

.hub__link:nth-child(2) {
  animation-delay: 0.14s;
}

.hub__link-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.hub__link-role {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 4.5vw, 2rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.hub__link--ops .hub__link-role {
  color: var(--ink);
}

.hub__link--driver .hub__link-role {
  color: var(--accent);
}

.hub__link-arrow {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 400;
  color: var(--ink-faint);
  transition: transform 0.22s var(--ease), color 0.22s var(--ease);
}

.hub__link-sub {
  display: block;
  margin-top: 0.35rem;
  font-family: var(--font-mono);
  font-size: clamp(0.64rem, 2.2vw, 0.72rem);
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--ink-muted);
  overflow-wrap: anywhere;
}

.hub__link-desc {
  display: block;
  margin-top: 0.5rem;
  max-width: 100%;
  font-size: clamp(0.82rem, 2.4vw, 0.88rem);
  line-height: 1.55;
  color: var(--ink-muted);
}

.hub__link:hover,
.hub__link.is-active {
  padding-left: 0.75rem;
  background: color-mix(in srgb, var(--accent-hit) 6%, transparent);
}

.hub__link:hover .hub__link-arrow,
.hub__link.is-active .hub__link-arrow {
  color: var(--accent);
  transform: translateX(4px);
}

.hub__link:active {
  transform: scale(0.998);
}

@media (max-width: 479px) {
  .hub__link:hover,
  .hub__link.is-active {
    padding-left: 0.5rem;
  }
}

.hub__link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

/* ── Scene illustration ── */

.hub__scene {
  width: 100%;
  max-width: 100%;
  margin: 0;
  min-width: 0;
  overflow: hidden;
  animation: fade-up 0.7s var(--ease) 0.12s both;
}

@media (max-width: 899px) {
  .hub__scene {
    max-height: 13rem;
    margin-top: 0.25rem;
    border-top: 1px solid var(--line);
    padding-top: 0.85rem;
  }
}

@media (min-width: 900px) {
  .hub__scene {
    position: sticky;
    top: calc(var(--pad) + env(safe-area-inset-top, 0px));
    align-self: start;
    max-height: none;
    border-top: 0;
    padding-top: 0;
    margin-top: 0;
  }
}

.scene {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  color: var(--scene-stroke);
}

.scene__bg {
  fill: color-mix(in srgb, var(--scene-fill) 92%, var(--bg));
}

.scene__grid-line {
  stroke: currentColor;
  opacity: 0.35;
}

.scene__frame {
  fill: var(--scene-fill);
  stroke: var(--scene-stroke);
  stroke-width: 1;
}

.scene__sidebar {
  fill: var(--scene-muted);
}

.scene__bar {
  fill: var(--scene-stroke);
  opacity: 0.5;
}

.scene__bar--accent {
  fill: var(--scene-accent);
  opacity: 0.85;
}

.scene__label {
  font-family: "JetBrains Mono", monospace;
  font-size: 9px;
  font-weight: 500;
  fill: var(--scene-ink);
  letter-spacing: 0.06em;
}

.scene__kpi {
  fill: var(--scene-muted);
  stroke: var(--scene-stroke);
  stroke-width: 0.75;
}

.scene__kpi--live {
  stroke: var(--scene-live);
  stroke-width: 1;
}

.scene__kpi-num {
  font-family: "Outfit", sans-serif;
  font-size: 18px;
  font-weight: 700;
  fill: var(--ink);
}

.dark .scene__kpi-num {
  fill: #f3f4f6;
}

.scene__kpi-num--live {
  fill: var(--scene-live);
}

.scene__kpi-label {
  font-family: "Noto Sans TC", sans-serif;
  font-size: 8px;
  fill: var(--scene-ink);
}

.scene__pulse-dot {
  fill: var(--scene-live);
  animation: pulse-dot 2.4s var(--ease) infinite;
}

.scene__chart-bg {
  fill: var(--scene-muted);
  stroke: var(--scene-stroke);
  stroke-width: 0.75;
}

.scene__chart-line {
  fill: none;
  stroke: var(--scene-accent);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 400;
  stroke-dashoffset: 400;
  animation: draw-line 2.8s var(--ease) 0.4s forwards, shimmer-line 4s var(--ease) 3.2s infinite;
}

.scene__chart-dot {
  fill: var(--scene-live);
  opacity: 0;
  animation: fade-in 0.4s var(--ease) 2.8s forwards, pulse-dot 2s var(--ease) 3s infinite;
}

.scene__divider {
  fill: var(--scene-stroke);
  opacity: 0.4;
}

.scene__row {
  fill: var(--scene-stroke);
  opacity: 0.45;
  animation: row-fade 3.6s var(--ease) infinite;
}

.scene__row--1 { animation-delay: 0s; }
.scene__row--2 { animation-delay: 0.4s; }
.scene__row--3 { animation-delay: 0.8s; }

.scene__route {
  fill: none;
  stroke-dasharray: 6 8;
  animation: route-flow 2.2s linear infinite;
}

.scene__route--down { animation-delay: 0s; }
.scene__route--up { animation-delay: 0.3s; }

.scene__route-dash {
  fill: none;
  stroke: var(--scene-accent);
  stroke-width: 1.25;
  stroke-linecap: round;
  stroke-dasharray: 4 6;
  opacity: 0.55;
  animation: route-flow 1.8s linear infinite reverse;
}

.scene__route-dash--b {
  animation-delay: 0.5s;
}

.scene__hub-ring {
  fill: none;
  stroke: var(--scene-accent);
}

.scene__hub-ring--outer {
  stroke-width: 1;
  opacity: 0.25;
  animation: hub-breathe 3.2s var(--ease) infinite;
}

.scene__hub-ring--inner {
  stroke-width: 1.25;
  opacity: 0.5;
}

.scene__truck {
  animation: truck-float 3.6s var(--ease) infinite;
  transform-origin: 260px 280px;
}

.scene__truck-body {
  fill: var(--scene-accent);
}

.scene__truck-cab {
  fill: color-mix(in srgb, var(--scene-accent) 70%, #ffffff);
}

.dark .scene__truck-cab {
  fill: color-mix(in srgb, var(--scene-accent) 60%, #111318);
}

.scene__truck-wheel {
  fill: var(--scene-ink);
}

.scene__ticket-bg {
  fill: var(--scene-muted);
  stroke: var(--scene-stroke);
  stroke-width: 0.75;
}

.scene__ticket--active .scene__ticket-bg {
  stroke: var(--scene-live);
  stroke-width: 1.25;
  animation: ticket-glow 2.8s var(--ease) infinite;
}

.scene__ticket-no {
  font-family: "Outfit", sans-serif;
  font-size: 12px;
  font-weight: 700;
  fill: var(--ink);
}

.dark .scene__ticket-no {
  fill: #f3f4f6;
}

.scene__ticket-meta {
  font-family: "JetBrains Mono", monospace;
  font-size: 8px;
  fill: var(--scene-ink);
}

.scene__ticket-badge {
  fill: var(--scene-live);
}

.scene__ticket-badge-text {
  font-family: "Noto Sans TC", sans-serif;
  font-size: 7px;
  font-weight: 600;
  fill: #ffffff;
}

.scene__ticket--queue {
  opacity: 0.72;
  animation: queue-wait 4s var(--ease) infinite;
}

.scene__queue-track {
  fill: var(--scene-muted);
}

.scene__queue-fill {
  fill: var(--scene-accent);
  animation: queue-progress 5s var(--ease) infinite;
  transform-origin: 44px 534px;
}

.scene__sync-pill {
  fill: var(--scene-fill);
  stroke: var(--scene-stroke);
  stroke-width: 0.75;
}

.scene__sync-dot {
  fill: #22c55e;
  animation: pulse-dot 2s var(--ease) infinite;
}

.scene__sync-text {
  font-family: "Noto Sans TC", sans-serif;
  font-size: 9px;
  font-weight: 600;
  fill: var(--scene-ink);
}

/* Scene hover states */

.scene__panel {
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
}

.hub.is-ops .scene__panel--driver {
  opacity: 0.45;
  transform: translateY(4px);
}

.hub.is-driver .scene__panel--ops {
  opacity: 0.45;
  transform: translateY(-4px);
}

.hub.is-ops .scene__panel--ops,
.hub.is-driver .scene__panel--driver {
  opacity: 1;
  transform: translateY(0);
}

/* ── Footer ── */

.hub__foot {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: flex-start;
  max-width: var(--max);
  width: 100%;
  margin: 0 auto;
  padding:
    1.25rem 0
    calc(1.25rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
  font-size: clamp(0.68rem, 2vw, 0.72rem);
  line-height: 1.5;
  color: var(--ink-muted);
}

@media (min-width: 640px) {
  .hub__foot {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
  }
}

@media (max-width: 639px) {
  .hub__foot span:last-child {
    overflow-wrap: anywhere;
  }
}

.hub__foot span:first-child {
  font-weight: 600;
  color: var(--ink);
}

/* ── Keyframes ── */

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade-in {
  to { opacity: 1; }
}

@keyframes draw-line {
  to { stroke-dashoffset: 0; }
}

@keyframes shimmer-line {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.85); }
}

@keyframes row-fade {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 0.85; }
}

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

@keyframes hub-breathe {
  0%, 100% { transform: scale(1); opacity: 0.25; }
  50% { transform: scale(1.06); opacity: 0.4; }
}

@keyframes truck-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

@keyframes ticket-glow {
  0%, 100% { filter: none; }
  50% { filter: brightness(1.08); }
}

@keyframes queue-wait {
  0%, 100% { opacity: 0.72; }
  50% { opacity: 0.95; }
}

@keyframes queue-progress {
  0% { transform: scaleX(0.28); }
  50% { transform: scaleX(0.62); }
  100% { transform: scaleX(0.28); }
}

@media (prefers-reduced-motion: reduce) {
  .hub__intro,
  .hub__link,
  .hub__scene,
  .hub__link-arrow,
  .scene * {
    animation: none !important;
    transition: none !important;
    transform: none !important;
    stroke-dashoffset: 0 !important;
    opacity: 1 !important;
  }
}
