/* Continuum chart room.
   A navigator's chart, not a control panel: flat chart blue, chalk lines,
   brass for what the Continuum holds, sea-glass for ships and trade, coral
   for danger.  Place names are set the way charts set them: italic serif. */

:root {
  --chart: #14284b;      /* the map sheet */
  --deep: #0e1d38;       /* panels, bar */
  --line: #2b426e;       /* rules and grid */
  --chalk: #ece7da;      /* text, charted sectors */
  --dim: #9fadc8;        /* secondary text */
  --brass: #e0a93b;      /* Continuum */
  --glass: #6fc7b5;      /* ships, trade */
  --coral: #ef6a4c;      /* hostile, losses */

  --ui: "Archivo", system-ui, sans-serif;
  --place: "Spectral", Georgia, serif;

  --s1: 0.25rem; --s2: 0.5rem; --s3: 0.75rem; --s4: 1rem; --s5: 1.5rem; --s6: 2.5rem;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--deep);
  color: var(--chalk);
  font: 400 0.9375rem/1.45 var(--ui);
  font-variant-numeric: tabular-nums;
}
h1, h2, p, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---- sign in ----------------------------------------------------------- */

body.login {
  display: grid;
  place-items: center;
  background: var(--chart);
  padding: var(--s4);
}
.login-card { width: min(23rem, 100%); }
.compass { width: 5.5rem; margin-bottom: var(--s5); }
.compass circle { fill: none; stroke: var(--line); stroke-width: 1.5; }
.compass .rose { fill: var(--brass); }
.login-card h1 {
  font: 600 3rem/1 var(--place);
  letter-spacing: -0.01em;
}
.lede {
  font: italic 400 1.125rem/1.4 var(--place);
  color: var(--dim);
  margin: var(--s3) 0 var(--s6);
}
.login-card label { display: block; font-weight: 600; margin-bottom: var(--s2); }
.login-card input {
  width: 100%;
  padding: 0.7rem 0.8rem;
  font: inherit;
  color: var(--chalk);
  background: var(--deep);
  border: 1.5px solid var(--line);
  border-radius: 4px;
}
.login-card input:focus { outline: none; border-color: var(--brass); }
.login-card button {
  margin-top: var(--s4);
  width: 100%;
  padding: 0.75rem;
  font-weight: 700;
  color: var(--deep);
  background: var(--brass);
  border: 0;
  border-radius: 4px;
}
.login-card button:disabled { opacity: 0.6; cursor: default; }
.error { margin-top: var(--s3); color: var(--coral); }

/* ---- frame ------------------------------------------------------------- */

body.app { display: flex; flex-direction: column; }

.bar {
  display: flex;
  align-items: baseline;
  gap: var(--s5);
  padding: var(--s3) var(--s5);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.brand {
  font: 600 1.5rem/1 var(--place);
  text-decoration: none;
}
.bar nav { display: flex; gap: var(--s4); }
.bar nav a {
  text-decoration: none;
  color: var(--dim);
  font-weight: 600;
  padding: var(--s1) 0;
  border-bottom: 2px solid transparent;
}
.bar nav a:hover { color: var(--chalk); }
.bar nav a[aria-current="page"] { color: var(--chalk); border-bottom-color: var(--brass); }
.status { margin-left: auto; color: var(--dim); font-size: 0.8125rem; }
.status::before {
  content: "";
  display: inline-block;
  width: 0.5rem; height: 0.5rem;
  margin-right: var(--s2);
  border-radius: 50%;
  background: var(--dim);
}
.status.live::before { background: var(--glass); }
.status.stale::before { background: var(--coral); }
.quiet {
  background: none;
  border: 0;
  color: var(--dim);
  font-size: 0.8125rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.quiet:hover { color: var(--chalk); }

.headline {
  padding: var(--s4) var(--s5);
  font: 400 1.375rem/1.3 var(--place);
  max-width: 62rem;
}
.headline b { font-weight: 600; color: var(--brass); }

main { flex: 1; min-height: 0; display: flex; }
.view { flex: 1; min-width: 0; padding: 0 var(--s5) var(--s5); }

/* ---- chart ------------------------------------------------------------- */

#view-chart {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 21rem;
  gap: var(--s5);
  min-height: 0;
}
.chart-wrap {
  position: relative;
  background: var(--chart);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  min-height: 26rem;
}
#chart { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
#chart.dragging { cursor: grabbing; }

.chart-tools {
  position: absolute;
  top: var(--s3); right: var(--s3);
  display: flex;
  gap: var(--s1);
}
.chart-tools button {
  min-width: 2.25rem;
  height: 2.25rem;
  padding: 0 var(--s3);
  background: var(--deep);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-weight: 600;
}
.chart-tools button:hover { border-color: var(--brass); }

#inset {
  position: absolute;
  right: var(--s3); bottom: var(--s3);
  width: 150px; height: 150px;
  background: var(--deep);
  border: 1px solid var(--line);
  border-radius: 50%;
}

.legend {
  position: absolute;
  left: var(--s3); bottom: var(--s3);
  padding: var(--s3) var(--s4);
  background: rgba(14, 29, 56, 0.88);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 0.8125rem;
  color: var(--dim);
}
.legend li { display: flex; align-items: center; gap: var(--s2); line-height: 1.7; }
.k { display: inline-block; width: 0.7rem; height: 0.7rem; flex: none; }
.k-claimed { background: var(--brass); }
.k-rock { background: var(--chalk); border-radius: 50%; }
.k-other { border: 2px solid var(--chalk); border-radius: 50%; }
.k-hostile { background: var(--coral); border-radius: 50%; }
.k-unseen { border: 1.5px dotted var(--dim); border-radius: 50%; }
.k-ship {
  width: 0; height: 0;
  border-left: 0.35rem solid transparent;
  border-right: 0.35rem solid transparent;
  border-bottom: 0.7rem solid var(--glass);
}
.k-player { border: 2px solid #fff; border-radius: 50%; background: var(--chart); }

.tip {
  position: absolute;
  pointer-events: none;
  padding: var(--s2) var(--s3);
  background: var(--deep);
  border: 1px solid var(--brass);
  border-radius: 4px;
  font-size: 0.8125rem;
  max-width: 16rem;
  z-index: 2;
}
.tip strong { font: italic 500 1rem/1.2 var(--place); display: block; }

/* ---- side panels ------------------------------------------------------- */

.side { display: flex; flex-direction: column; gap: var(--s5); min-height: 0; }
.panel h2 {
  font: 600 1.125rem/1.2 var(--place);
  padding-bottom: var(--s2);
  margin-bottom: var(--s3);
  border-bottom: 1px solid var(--line);
}
.hint, .empty { color: var(--dim); }
.empty { padding: var(--s4) 0; max-width: 40rem; }

#detail .where { font: italic 500 1.375rem/1.2 var(--place); }
#detail dl { margin: var(--s3) 0 0; display: grid; grid-template-columns: auto 1fr; gap: var(--s1) var(--s4); }
#detail dt { color: var(--dim); }
#detail dd { margin: 0; }
#detail ul { margin-top: var(--s3); }
#detail li { padding: var(--s1) 0; border-top: 1px solid var(--line); }
#detail li em { font: italic 500 1rem var(--place); }

.side .panel:last-child { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.log { overflow-y: auto; flex: 1; min-height: 8rem; max-height: 46vh; }
.log li {
  padding: var(--s2) 0 var(--s2) var(--s3);
  border-left: 3px solid var(--line);
  margin-bottom: var(--s2);
}
.log li time { display: block; color: var(--dim); font-size: 0.75rem; }
.log li.claim, .log li.build, .log li.founding { border-left-color: var(--brass); }
.log li.trade, .log li.explore { border-left-color: var(--glass); }
.log li.loss, .log li.battle { border-left-color: var(--coral); }

/* ---- tables ------------------------------------------------------------ */

.tallies { display: flex; gap: var(--s6); flex-wrap: wrap; padding: var(--s2) 0 var(--s5); }
.tallies div { min-width: 5rem; }
.tallies b { display: block; font: 600 2.25rem/1 var(--place); }
.tallies span { color: var(--dim); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-weight: 600;
  color: var(--dim);
  padding: var(--s2) var(--s4) var(--s2) 0;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td { padding: var(--s2) var(--s4) var(--s2) 0; border-bottom: 1px solid var(--line); }
td.name { font: italic 500 1.0625rem var(--place); white-space: nowrap; }
td a { text-decoration-color: var(--line); text-underline-offset: 3px; }
td a:hover { text-decoration-color: var(--brass); }
.tag {
  display: inline-block;
  padding: 0 var(--s2);
  border-radius: 3px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--deep);
  background: var(--dim);
}
.tag.mine, .tag.haul, .tag.unload { background: var(--glass); }
.tag.expand, .tag.claim, .tag.explore { background: var(--brass); }
.tag.defend, .tag.patrol { background: var(--coral); }
.tag.travel { background: var(--chalk); }

.building { padding: var(--s2) 0 var(--s4); }
.building p { padding: var(--s2) 0; }
.building progress { width: min(22rem, 100%); height: 0.5rem; accent-color: var(--brass); display: block; margin-top: var(--s1); }

.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); gap: var(--s6); }
.row { display: grid; grid-template-columns: 6.5rem 1fr auto; gap: var(--s3); align-items: center; padding: var(--s1) 0; }
.row .meter { height: 0.5rem; background: var(--line); border-radius: 2px; overflow: hidden; }
.row .meter i { display: block; height: 100%; background: var(--brass); }
.row.trait .meter i { background: var(--glass); }
.plain li { padding: var(--s2) 0; border-bottom: 1px solid var(--line); }
.plain li em { font: italic 500 1.0625rem var(--place); }

/* ---- small screens ----------------------------------------------------- */

@media (max-width: 60rem) {
  main { display: block; }
  #view-chart { grid-template-columns: 1fr; }
  .chart-wrap { height: 62vh; }
  .log { max-height: none; }
  .legend { display: none; }
  #inset { width: 96px; height: 96px; }
}
@media (max-width: 36rem) {
  .bar { padding: var(--s3) var(--s4); gap: var(--s3); }
  .status { margin-left: 0; order: 5; width: 100%; }
  .headline { padding: var(--s3) var(--s4); font-size: 1.125rem; }
  .view { padding: 0 var(--s4) var(--s4); }
}
