/* ============================================================
   Portside — shared design system
   Canonical tokens, base, and shared components.
   Page <style> blocks remain as page-specific overrides.
   ============================================================ */

:root {
  --bg:            #FAF9F6;
  --bg-alt:        #F3F1EB;
  --surface:       #FFFFFF;
  --surface-2:     #F8F7F3;
  --stroke:        #E4E1D7;
  --stroke-strong: #D2CFC4;
  --text:          #23272C;
  --text-soft:     #4B5158;
  --text-mute:     #7A8087;
  --accent:        #495E91;
  --accent-soft:   #E4E7EF;
  --accent-hover:  #3A4B78;
  --success:       #4A8C64;
  --danger:        #B4544F;
  --shadow-sm:     0 1px 2px rgba(20,24,30,.04), 0 2px 6px rgba(20,24,30,.04);
  --shadow-md:     0 4px 12px rgba(20,24,30,.06), 0 12px 32px rgba(20,24,30,.06);
  --shadow-lg:     0 8px 24px rgba(20,24,30,.08), 0 24px 64px rgba(20,24,30,.08);
  --radius-sm:     10px;
  --radius:        14px;
  --radius-lg:     22px;
  --radius-xl:     28px;
  --ease:          cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out:      cubic-bezier(0.16, 1, 0.3, 1);
  --dur-1:         .2s;
  --dur-2:         .45s;
  --dur-3:         .8s;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:            #101114;
    --bg-alt:        #15171B;
    --surface:       #1D1F24;
    --surface-2:     #23262D;
    --stroke:        #2E3138;
    --stroke-strong: #3E424B;
    --text:          #EBEEF3;
    --text-soft:     #C4C9D1;
    --text-mute:     #8D939C;
    --accent:        #4A87FF;
    --accent-soft:   #17233A;
    --accent-hover:  #6C9EFF;
    --success:       #6FB58A;
    --danger:        #F0807A;
    --shadow-sm:     0 1px 2px rgba(0,0,0,.4), 0 2px 8px rgba(0,0,0,.25);
    --shadow-md:     0 4px 16px rgba(0,0,0,.45), 0 16px 40px rgba(0,0,0,.3);
    --shadow-lg:     0 8px 32px rgba(0,0,0,.55), 0 32px 80px rgba(0,0,0,.4);
  }
}

[data-theme="dark"] {
  --bg:            #101114;
  --bg-alt:        #15171B;
  --surface:       #1D1F24;
  --surface-2:     #23262D;
  --stroke:        #2E3138;
  --stroke-strong: #3E424B;
  --text:          #EBEEF3;
  --text-soft:     #C4C9D1;
  --text-mute:     #8D939C;
  --accent:        #4A87FF;
  --accent-soft:   #17233A;
  --accent-hover:  #6C9EFF;
  --success:       #6FB58A;
  --danger:        #F0807A;
  --shadow-sm:     0 1px 2px rgba(0,0,0,.4), 0 2px 8px rgba(0,0,0,.25);
  --shadow-md:     0 4px 16px rgba(0,0,0,.45), 0 16px 40px rgba(0,0,0,.3);
  --shadow-lg:     0 8px 32px rgba(0,0,0,.55), 0 32px 80px rgba(0,0,0,.4);
}

/* ------------------------------------------------------------ base */

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

[hidden] { display: none !important; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
               'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color .35s var(--ease), color .35s var(--ease);
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }

::selection { background: var(--accent-soft); color: var(--text); }

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

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 200;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  font-weight: 600;
  transition: top var(--dur-1) var(--ease);
}
.skip-link:focus { top: 12px; }

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ------------------------------------------------------------ header */

header {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border-bottom: 1px solid transparent;
  transition: border-color .3s var(--ease), background-color .35s var(--ease);
}
header.scrolled { border-bottom-color: var(--stroke); }

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.01em;
}
.brand-icon {
  font-size: 22px;
  color: var(--accent);
  flex-shrink: 0;
  line-height: 1;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-links a {
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-soft);
  border-radius: var(--radius-sm);
  transition: color .2s, background-color .2s;
}
.nav-links a:hover { color: var(--text); background: var(--surface-2); }

.theme-toggle {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--stroke);
  color: var(--text-soft);
  transition: color .2s, border-color .2s, transform .2s var(--ease);
}
.theme-toggle:hover { color: var(--text); border-color: var(--stroke-strong); }
.theme-toggle:active { transform: scale(.94); }

/* ------------------------------------------------------------ type + sections */

.kicker {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}

.section-head {
  max-width: 640px;
  margin: 0 auto 40px;
  text-align: center;
}
.section-head h2 {
  font-size: clamp(24px, 3vw, 32px);
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-weight: 800;
  margin: 0 0 12px;
}
.section-head p { font-size: 16px; color: var(--text-soft); margin: 0; }

/* ------------------------------------------------------------ buttons */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 12px 22px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 15px;
  transition: transform .2s var(--ease), background-color .2s,
              box-shadow .25s, border-color .2s, color .2s;
  will-change: transform;
}
.btn:active { transform: translateY(1px) scale(.99); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--stroke);
}
.btn-ghost:hover {
  border-color: var(--stroke-strong);
  transform: translateY(-1px);
}

/* ------------------------------------------------------------ reveal */

.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity .65s var(--ease), transform .65s var(--ease);
}
.reveal.in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* ------------------------------------------------------------ premium silver pill */

.mp-silver {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #39404a;
  border-radius: 999px;
  background: linear-gradient(135deg,#ffffff 0%,#e6ebf3 28%,#c2cbd9 52%,#eef2f8 72%,#ccd4e1 100%);
  border: 1px solid #c3ccd9;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.95),
              inset 0 -1px 0 rgba(120,132,150,.18),
              0 3px 10px rgba(20,24,30,.12);
  text-shadow: 0 1px 0 rgba(255,255,255,.8);
}
[data-theme="dark"] .mp-silver {
  color: #eef1f6;
  background: linear-gradient(135deg,#454b55 0%,#6b7381 30%,#98a1b0 52%,#5a6270 74%,#3e444d 100%);
  border-color: #78818f;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.22),
              inset 0 -1px 0 rgba(0,0,0,.35),
              0 3px 12px rgba(0,0,0,.45);
  text-shadow: 0 1px 1px rgba(0,0,0,.45);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .mp-silver {
    color: #eef1f6;
    background: linear-gradient(135deg,#454b55 0%,#6b7381 30%,#98a1b0 52%,#5a6270 74%,#3e444d 100%);
    border-color: #78818f;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.22),
                inset 0 -1px 0 rgba(0,0,0,.35),
                0 3px 12px rgba(0,0,0,.45);
    text-shadow: 0 1px 1px rgba(0,0,0,.45);
  }
}

/* ------------------------------------------------------------ footer */

footer {
  border-top: 1px solid var(--stroke);
  padding: 40px 0;
  margin-top: 64px;
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-between;
  align-items: center;
  font-size: 13.5px;
  color: var(--text-mute);
}
.footer-links {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}
.footer-links a { color: var(--text-mute); }
.footer-links a:hover { color: var(--text); }

/* ============================================================
   A* live route-search demo
   ============================================================ */

.astar-demo {
  --astar-sea: var(--surface-2);
  --astar-land: color-mix(in srgb, var(--text-mute) 22%, var(--surface));
  --astar-land-edge: color-mix(in srgb, var(--text-mute) 38%, var(--surface));
  max-width: 960px;
  margin: 0 auto 56px;
  scroll-margin-top: 90px;
  padding: clamp(20px, 3vw, 30px);
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.astar-head {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 18px;
}
.astar-kicker {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}
.astar-kicker::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  animation: astar-pulse 1.8s ease-in-out infinite;
}
@keyframes astar-pulse {
  0%, 100% { opacity: .35; transform: scale(.85); }
  50%      { opacity: 1; transform: scale(1); }
}
.astar-head h3 {
  font-size: clamp(20px, 2.4vw, 26px);
  font-weight: 800;
  letter-spacing: -0.015em;
  margin: 0 0 6px;
}
.astar-head p {
  margin: 0;
  font-size: 14.5px;
  color: var(--text-soft);
  max-width: 520px;
}
.astar-stats {
  display: flex;
  gap: 22px;
  font-size: 12.5px;
  color: var(--text-mute);
}
.astar-stats b {
  display: block;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.astar-stage {
  position: relative;
  border-radius: calc(var(--radius-lg) - 6px);
  overflow: hidden;
  border: 1px solid var(--stroke);
  background: var(--astar-sea);
}
.astar-stage canvas {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 1;
  height: auto;
}
.astar-legend {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  padding: 7px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: 11px;
  color: var(--text-mute);
}
.astar-legend span { display: inline-flex; align-items: center; gap: 6px; }
.astar-legend i {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  display: inline-block;
}
.astar-legend .lg-sea  { background: var(--astar-sea); border: 1px solid var(--stroke); }
.astar-legend .lg-land { background: var(--astar-land); }
.astar-legend .lg-route { background: var(--accent); border-radius: 50%; }

.astar-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}
.astar-status {
  font-size: 13px;
  color: var(--text-mute);
  font-variant-numeric: tabular-nums;
}
.astar-status b { color: var(--text); font-weight: 600; }

@media (max-width: 560px) {
  .astar-head { align-items: flex-start; }
  .astar-stats { gap: 16px; }
  .astar-stats b { font-size: 17px; }
  .astar-legend { display: none; }
}
