/* ============================================================
   GIGA Traceroute Studies — "Signal & Route" dashboard theme
   ============================================================ */
:root {
  --ink: #0a1a2b;
  --ink-2: #35506a;
  --navy: #0b2942;
  --navy-2: #123b5e;
  --navy-3: #0e3350;
  --paper: #f4f7fb;
  --surface: #ffffff;
  --line: #e2e9f1;
  --line-2: #d2ddea;
  --signal: #ff5c39;      /* coral — action / accent */
  --signal-ink: #c53a1c;
  --data: #109a86;        /* teal — data highlight */
  --data-soft: #e2f4f0;
  --shadow-sm: 0 1px 2px rgba(10, 26, 43, .06), 0 2px 8px rgba(10, 26, 43, .05);
  --shadow-md: 0 6px 24px rgba(10, 26, 43, .10);
  --shadow-lg: 0 20px 50px rgba(10, 26, 43, .18);
  --r: 14px;
  --maxw: 1080px;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Libre Franklin", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: var(--serif);
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  line-height: 1.55;
  background: var(--paper);
  background-image:
    radial-gradient(1100px 480px at 88% -8%, rgba(18, 59, 94, .06), transparent 60%),
    radial-gradient(900px 420px at -5% 6%, rgba(16, 154, 134, .05), transparent 55%);
  -webkit-font-smoothing: antialiased;
}

main { max-width: var(--maxw); margin: 0 auto; padding: 2rem 1.4rem 3rem; }

::selection { background: var(--signal); color: #fff; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .85rem 1.4rem;
  background: linear-gradient(100deg, var(--navy), var(--navy-2));
  color: #fff; position: sticky; top: 0; z-index: 40;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand { display: inline-flex; align-items: center; gap: .6rem; text-decoration: none; color: #fff; }
.brand-mark {
  width: 18px; height: 18px; border-radius: 5px;
  background: conic-gradient(from 140deg, var(--signal), #ffb199, var(--data), var(--signal));
  box-shadow: 0 0 0 3px rgba(255,255,255,.10);
}
.brand-name { font-family: var(--display); font-weight: 700; letter-spacing: .2px; font-size: 1.05rem; }
.brand-dim { font-weight: 500; opacity: .72; }
.topbar-tag { font-family: var(--mono); font-size: .72rem; letter-spacing: .04em; text-transform: uppercase; opacity: .7; }
/* Org logos sit on a white chip so the blue/dark marks stay legible on the navy bar */
.topbar-logos { display: flex; align-items: center; gap: .9rem; background: #fff; padding: .32rem .7rem; border-radius: 8px; box-shadow: var(--shadow-sm); }
.topbar-logos a { display: inline-flex; }
.org-logo { height: 22px; width: auto; display: block; }
@media (max-width: 520px) { .org-logo { height: 18px; } .topbar-logos { gap: .55rem; padding: .28rem .5rem; } }

/* ---------- hero ---------- */
.hero {
  position: relative; overflow: hidden; color: #eaf2fb;
  background: radial-gradient(140% 120% at 78% -20%, #17466e 0%, var(--navy) 46%, #071d31 100%);
  border-radius: 22px;
  padding: clamp(2.4rem, 6vw, 4.4rem);
  margin-bottom: 2.6rem;
  box-shadow: var(--shadow-lg);
}
.hero-glow {
  position: absolute; width: 460px; height: 460px; right: -90px; top: -140px;
  background: radial-gradient(circle, rgba(255,92,57,.42), transparent 62%);
  filter: blur(14px); pointer-events: none;
}
.hero-routes { position: absolute; inset: 0; opacity: .5; pointer-events: none; }
.hero-routes svg { width: 100%; height: 100%; }
.hero-routes path {
  fill: none; stroke: url(#g); stroke: rgba(150,205,235,.28); stroke-width: 1.4;
  stroke-dasharray: 5 7;
  animation: dash 26s linear infinite;
}
.hero-routes path:nth-child(2) { stroke: rgba(255,150,120,.26); animation-duration: 34s; }
.hero-routes path:nth-child(3) { stroke: rgba(120,225,205,.22); animation-duration: 30s; }
@keyframes dash { to { stroke-dashoffset: -240; } }

.hero-inner { position: relative; max-width: 46rem; }
.eyebrow {
  font-family: var(--mono); text-transform: uppercase; letter-spacing: .16em;
  font-size: .72rem; color: #9fd0e6; margin: 0 0 1rem;
}
.hero-title {
  font-family: var(--display); font-weight: 700; line-height: 1.06;
  font-size: clamp(2.2rem, 5.4vw, 3.6rem); margin: 0 0 1.1rem; letter-spacing: -.1px;
}
.hero-title em { font-style: italic; color: var(--signal); }
.hero-lede { font-size: 1.08rem; color: #cfe0f0; max-width: 40rem; margin: 0 0 1.8rem; }

.stat-row { display: flex; flex-wrap: wrap; gap: 2.4rem; margin-bottom: 1.9rem; }
.stat { display: flex; flex-direction: column; }
.stat-num { font-family: var(--display); font-weight: 700; font-size: 2.1rem; color: #fff; line-height: 1; }
.stat-lab { font-family: var(--mono); font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: #93b6d1; margin-top: .35rem; }

.hero-cta {
  display: inline-flex; align-items: center; gap: .5rem;
  background: var(--signal); color: #fff; text-decoration: none;
  font-weight: 600; padding: .7rem 1.3rem; border-radius: 999px;
  box-shadow: 0 8px 22px rgba(255,92,57,.35); transition: transform .15s, box-shadow .15s;
}
.hero-cta:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(255,92,57,.45); }

/* ---------- section kicker ---------- */
.section-kicker {
  font-family: var(--mono); text-transform: uppercase; letter-spacing: .14em;
  font-size: .74rem; color: var(--ink-2); margin: 0 0 1.2rem;
  display: flex; align-items: center; gap: .8rem;
}
.section-kicker::after { content: ""; flex: 1; height: 1px; background: var(--line-2); }

.howto, .countries, .method { margin-bottom: 3rem; }

/* ---------- how-to steps ---------- */
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.step {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 1.3rem 1.2rem 1.2rem; box-shadow: var(--shadow-sm); position: relative;
}
.step-n {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 9px; margin-bottom: .7rem;
  font-family: var(--mono); font-weight: 500; font-size: .9rem;
  background: var(--data-soft); color: var(--data);
}
.step h3 { font-family: var(--display); font-weight: 700; font-size: 1.05rem; margin: 0 0 .35rem; }
.step p { margin: 0; color: var(--ink-2); font-size: .92rem; }

/* ---------- country grid ---------- */
.country-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.country-card {
  position: relative; display: flex; flex-direction: column; gap: .45rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 1.3rem; text-decoration: none; color: var(--ink);
  box-shadow: var(--shadow-sm); overflow: hidden;
  transition: transform .16s, box-shadow .16s, border-color .16s;
  animation: rise .5s both; animation-delay: calc(var(--i) * 55ms);
}
.country-card::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 4px;
  background: linear-gradient(var(--signal), var(--data)); opacity: 0; transition: opacity .16s;
}
.country-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--line-2); }
.country-card:hover::before { opacity: 1; }
.country-card:hover .cc-go { transform: translateX(3px); opacity: 1; }
.cc-flag { display: inline-flex; width: 46px; height: 32px; }
.cc-flag img { width: 100%; height: 100%; object-fit: cover; border-radius: 4px; border: 1px solid var(--line-2); box-shadow: var(--shadow-sm); }
.flag-fallback { display: none; font-size: 1.9rem; line-height: 1; }
.cc-name { font-family: var(--display); font-weight: 700; font-size: 1.25rem; }
.cc-meta { display: flex; flex-direction: column; gap: .1rem; }
.cc-months { font-weight: 600; color: var(--ink); font-size: .9rem; }
.cc-latest { font-family: var(--mono); font-size: .74rem; color: var(--ink-2); }
.cc-badge {
  align-self: flex-start; margin-top: .3rem;
  font-family: var(--mono); font-size: .66rem; letter-spacing: .05em; text-transform: uppercase;
  background: #fdeee9; color: var(--signal-ink); border: 1px solid #f8d5ca;
  padding: .12rem .5rem; border-radius: 999px;
}
.cc-go { position: absolute; right: 1.1rem; top: 1.1rem; color: var(--signal); font-size: 1.2rem; opacity: .5; transition: transform .16s, opacity .16s; }

/* ---------- method note ---------- */
.method p {
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--data);
  border-radius: var(--r); padding: 1.4rem 1.5rem; margin: 0; color: var(--ink-2);
  box-shadow: var(--shadow-sm); max-width: 62rem;
}

/* ---------- country page head ---------- */
.crumb { margin-bottom: 1rem; }
.crumb a { font-family: var(--mono); font-size: .8rem; color: var(--ink-2); text-decoration: none; }
.crumb a:hover { color: var(--signal); }
.country-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.4rem; }
.country-flag { display: inline-flex; width: 68px; height: 48px; flex: none; }
.country-flag img { width: 100%; height: 100%; object-fit: cover; border-radius: 6px; border: 1px solid var(--line-2); box-shadow: var(--shadow-sm); }
.country-title { font-family: var(--display); font-weight: 700; font-size: clamp(1.9rem, 4.4vw, 2.7rem); margin: 0; letter-spacing: 0; }
.country-sub { margin: .25rem 0 0; color: var(--ink-2); max-width: 46rem; font-size: .95rem; }

/* ---------- sticky controls ---------- */
.controls {
  position: sticky; top: 54px; z-index: 30;
  background: rgba(255,255,255,.86); backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: var(--r);
  padding: .95rem 1.1rem; margin-bottom: 1.8rem; box-shadow: var(--shadow-sm);
}
.tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .9rem; }
.tab {
  font-family: var(--sans); font-weight: 600; font-size: .86rem;
  border: 1px solid var(--line-2); background: #fff; color: var(--ink-2);
  padding: .42rem .95rem; border-radius: 999px; cursor: pointer;
  transition: all .14s;
}
.tab:hover { border-color: var(--navy-2); color: var(--navy-2); }
.tab.active { background: var(--navy); color: #fff; border-color: var(--navy); box-shadow: var(--shadow-sm); }
.tab-security.active { background: var(--signal); border-color: var(--signal); }

.month-controls { display: flex; align-items: flex-start; gap: 1.2rem; flex-wrap: wrap; }

/* Historical timeline: labelled month stops on a connecting track */
.timeline { position: relative; display: flex; flex-wrap: wrap; row-gap: .6rem; padding: .3rem 0 .1rem; }
.tl-node {
  position: relative; z-index: 1; background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: .4rem;
  padding: 0 1.15rem; font-family: var(--mono);
}
.tl-node::before {  /* connector to the previous stop */
  content: ""; position: absolute; top: 6px; right: 50%; width: 100%; height: 2px;
  background: var(--line-2); z-index: -1;
}
.tl-node:first-child::before { display: none; }
.tl-dot {
  width: 14px; height: 14px; border-radius: 50%; background: #fff;
  border: 2px solid var(--line-2); transition: all .14s;
}
.tl-label { font-size: .78rem; color: var(--ink-2); letter-spacing: .02em; white-space: nowrap; transition: color .14s; }
.tl-node:hover .tl-dot { border-color: var(--navy-2); }
.tl-node:hover .tl-label { color: var(--navy-2); }
.tl-node.active .tl-dot { background: var(--signal); border-color: var(--signal); box-shadow: 0 0 0 4px rgba(255,92,57,.16); }
.tl-node.active .tl-label { color: var(--ink); font-weight: 600; }

.range-selector { display: flex; gap: .35rem; flex-wrap: wrap; align-self: center; }
.range-btn {
  font-family: var(--mono); font-size: .76rem; cursor: pointer;
  border: 1px solid var(--line-2); background: #fff; color: var(--ink-2);
  padding: .28rem .6rem; border-radius: 8px; transition: all .14s;
}
.range-btn:hover { border-color: var(--data); color: var(--data); }
.range-btn.active { background: var(--data); color: #fff; border-color: var(--data); }

/* ---------- analysis sections ---------- */
.analysis {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 1.5rem 1.6rem; margin-bottom: 1.15rem; box-shadow: var(--shadow-sm);
  animation: rise .45s both; animation-delay: calc(var(--i) * 40ms);
}
.analysis-head { display: flex; align-items: baseline; gap: .8rem; }
.analysis-num { font-family: var(--mono); font-size: .82rem; color: var(--signal); font-weight: 500; }
.analysis h2 { font-family: var(--display); font-weight: 700; font-size: 1.35rem; margin: 0; letter-spacing: -.2px; }
.analysis-blurb { margin: .5rem 0 0; color: var(--ink-2); font-size: .96rem; max-width: 54rem; }
.analysis-empty { font-family: var(--mono); font-size: .82rem; color: #9aa9b8; margin: .9rem 0 0; }

.narrative { margin-top: 1rem; color: var(--ink); font-family: var(--serif); font-size: 1.05rem; line-height: 1.7; }
.analysis-blurb { font-family: var(--serif); font-style: italic; }
.narrative :is(h3, h4) { font-family: var(--display); font-weight: 700; margin: 1.3rem 0 .5rem; font-size: 1.02rem; }
.narrative p { margin: .5rem 0; }
.narrative hr { border: none; border-top: 1px solid var(--line); margin: 1.2rem 0; }
.narrative code { font-family: var(--mono); font-size: .85em; background: var(--paper); padding: .1em .35em; border-radius: 5px; }
.narrative table {
  border-collapse: collapse; width: 100%; margin: .8rem 0; font-size: .88rem;
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
}
.narrative thead { background: var(--paper); }
.narrative th { font-family: var(--mono); font-weight: 500; text-transform: uppercase; letter-spacing: .03em; font-size: .74rem; color: var(--ink-2); }
.narrative th, .narrative td { padding: .5rem .7rem; text-align: left; border-bottom: 1px solid var(--line); }
.narrative tbody tr:last-child td { border-bottom: none; }
.narrative tbody tr:hover { background: #fafcfe; }
.narrative td:not(:first-child) { font-family: var(--mono); }

/* ---------- plot disclosure ---------- */
details.plots { margin-top: 1.1rem; border-top: 1px dashed var(--line-2); padding-top: .9rem; }
details.plots summary {
  cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: .55rem;
  font-weight: 600; font-size: .9rem; color: var(--navy-2);
  background: var(--data-soft); border: 1px solid #cfeae4; padding: .5rem .95rem; border-radius: 999px;
  transition: background .14s, color .14s;
}
details.plots summary::-webkit-details-marker { display: none; }
details.plots summary::before { content: "▸"; color: var(--data); transition: transform .16s; }
details.plots[open] summary::before { transform: rotate(90deg); }
details.plots summary:hover { background: #d3efe9; color: var(--data); }
.plot-holder { display: grid; gap: 1rem; margin-top: 1rem; }
.plot-frame { width: 100%; height: 560px; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: var(--shadow-sm); }

/* ---------- security panel ---------- */
.security-panel {
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--signal);
  border-radius: 16px; padding: 1.6rem 1.8rem; box-shadow: var(--shadow-sm); color: var(--ink);
}
.security-panel :is(h1, h2, h3) { font-family: var(--display); }
.security-panel h1 { font-size: 1.5rem; margin-top: 0; }
.security-panel table { border-collapse: collapse; width: 100%; margin: .8rem 0; font-size: .88rem; }
.security-panel th, .security-panel td { padding: .5rem .7rem; text-align: left; border-bottom: 1px solid var(--line); }
.security-panel th { font-family: var(--mono); font-size: .74rem; text-transform: uppercase; color: var(--ink-2); }
.security-panel code { font-family: var(--mono); background: var(--paper); padding: .1em .35em; border-radius: 5px; }

/* ---------- server info popup ---------- */
.server-link {
  font-family: var(--mono); font-size: inherit; color: var(--navy-2);
  background: none; border: none; padding: 0; cursor: pointer;
  border-bottom: 1px dashed var(--data); line-height: 1.2;
}
.server-link:hover { color: var(--signal); border-bottom-color: var(--signal); }
.server-popup {
  position: absolute; z-index: 60; width: min(320px, 90vw);
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 12px;
  box-shadow: var(--shadow-lg); padding: .9rem 1rem 1rem;
  font-family: var(--sans); font-size: .86rem; color: var(--ink);
}
.sp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .55rem; }
.sp-site { font-family: var(--mono); font-weight: 500; font-size: 1rem; color: var(--ink); }
.sp-close { background: none; border: none; font-size: 1.2rem; line-height: 1; color: var(--ink-2); cursor: pointer; padding: 0 .2rem; }
.sp-close:hover { color: var(--signal); }
.server-popup dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: .3rem .8rem; }
.server-popup dt { font-family: var(--mono); font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); padding-top: .1rem; }
.server-popup dd { margin: 0; }
.server-popup a { color: var(--navy-2); }
.sp-dim { color: var(--ink-2); }

/* ---------- footer ---------- */
.site-foot {
  max-width: var(--maxw); margin: 2rem auto 0; padding: 1.6rem 1.4rem;
  border-top: 1px solid var(--line); display: flex; justify-content: space-between;
  flex-wrap: wrap; gap: .5rem; color: var(--ink-2); font-size: .85rem;
}
.site-foot span:first-child { font-family: var(--display); font-weight: 700; color: var(--ink); }
.foot-dim { font-family: var(--mono); font-size: .74rem; }
.foot-feedback { color: var(--navy-2); font-weight: 600; text-decoration: none; }
.foot-feedback:hover { color: var(--signal); }

@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; scroll-behavior: auto; }
}

@media (max-width: 640px) {
  .controls { top: 50px; }
  .analysis { padding: 1.2rem; }
  .hero { padding: 2rem 1.4rem; }
}

/* ---------- raw-data download bar ---------- */
.dataset-download {
  display: flex; align-items: center; flex-wrap: wrap; gap: .6rem .9rem;
  margin: 0 0 1.15rem; padding: .75rem 1rem;
  background: var(--data-soft); border: 1px solid var(--line);
  border-radius: 12px;
}
.download-btn {
  display: inline-flex; align-items: baseline; gap: .5rem;
  font-family: var(--sans); font-weight: 600; font-size: .86rem;
  text-decoration: none; color: #fff; background: var(--data);
  padding: .48rem .95rem; border-radius: 999px; transition: all .14s;
}
.download-btn:hover { background: #0d8272; box-shadow: var(--shadow-sm); }
.download-btn .dl-icon { font-weight: 700; }
.download-btn .dl-file { font-family: var(--mono); font-size: .74rem; opacity: .85; }
.download-note { font-size: .8rem; color: var(--ink-2); }

/* ---------- interesting example paths ---------- */
.ipaths { display: flex; flex-direction: column; gap: .7rem; }
.ipath { border: 1px solid var(--line); border-radius: 12px; background: #fff; overflow: hidden; }
.ipath[open] { box-shadow: var(--shadow-sm); }
.ipath-sum {
  list-style: none; cursor: pointer; padding: .7rem .95rem;
  display: flex; flex-wrap: wrap; align-items: baseline; gap: .35rem .8rem;
}
.ipath-sum::-webkit-details-marker { display: none; }
.ipath-sum::before { content: "▸"; color: var(--ink-2); font-size: .8rem; }
.ipath[open] .ipath-sum::before { content: "▾"; }
.ipath-reason { font-family: var(--sans); font-weight: 700; color: var(--navy); font-size: .9rem; }
.ipath-route { font-family: var(--mono); font-size: .76rem; color: var(--ink-2); }
.ipath-body { padding: 0 .95rem .9rem; }
.ip-chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .2rem 0 .6rem; }
.ip-chip {
  font-family: var(--mono); font-size: .72rem; color: var(--ink-2);
  background: var(--paper); border: 1px solid var(--line); border-radius: 999px;
  padding: .15rem .55rem;
}
.ipath-summary { display: flex; flex-wrap: wrap; gap: .25rem 1.4rem; margin-bottom: .6rem;
  font-family: var(--mono); font-size: .76rem; color: var(--ink); }
.ip-k { display: inline-block; min-width: 4.4rem; color: var(--signal-ink); font-weight: 600; }
.ipath-hops { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: .74rem; }
.ipath-hops th { text-align: left; color: var(--ink-2); font-weight: 600;
  border-bottom: 1px solid var(--line-2); padding: .28rem .45rem; }
.ipath-hops td { padding: .24rem .45rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.ip-ttl { color: var(--ink-2); text-align: right; }
.ip-rtt { text-align: right; }
.ip-flag { font-size: .68rem; padding: .05rem .4rem; border-radius: 999px; white-space: nowrap; }
.ip-flag-as { background: #fdeae4; color: var(--signal-ink); }
.ip-flag-country { background: #e6eefb; color: var(--navy-2); }
.ip-flag-ixp { background: var(--data-soft); color: #0d8272; }
.ip-asn { display: inline-block; color: #fff; font-size: .7rem; font-weight: 600;
  padding: .04rem .4rem; border-radius: 6px; white-space: nowrap; }
.ipath-summary .ip-asn { margin: 0 .05rem; }
.ipath-hops td:first-child { border-left: 3px solid transparent; }

/* ---------- per-section data-source label ---------- */
.ds-chip {
  margin-left: auto; align-self: center;         /* right side of the header */
  font-family: var(--sans); font-size: .67rem; font-weight: 700;
  padding: .2rem .58rem; border-radius: 999px; white-space: nowrap;
  border: 1px solid transparent; cursor: default;
}
.ds-traceroute { background: var(--data-soft); color: #0d8272; border-color: #b8e6dd; }
.ds-traceroute-ndt { background: #e8eefb; color: var(--navy-2); border-color: #c9d8f2; }
