/* Central theme (spec §6: "do not hardcode colours into business logic" --
   map.js/panels.js read these via getComputedStyle rather than embedding
   hex values, so retheming never touches JS). Palette follows the sibling
   apps' "eve-panel" dark slate/sky look (see ~/Blueprints/CLAUDE.md's
   restyle notes: slate-900 panels with a faint sky gradient bleeding down
   from the top edge, slate-700/800 borders, angled-corner clip-path
   frames) so this reads as part of the same eveiskflow.com family. */
:root {
  --bg: #0b1120;
  --panel-bg: #0f172a;
  --panel-border: #1e293b;
  --panel-border-light: #334155;
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --accent: #38bdf8;
  --accent-dim: #0ea5e9;
  --danger: #f87171;

  /* Security-status visual hierarchy (spec §6). */
  --sec-highsec: #38bdf8;
  --sec-lowsec: #fbbf24;
  --sec-nullsec: #f87171;
  --sec-unknown: #a78bfa;

  /* Online/offline/stale character status (spec §11). */
  --status-online: #34d399;
  --status-offline: #64748b;
  --status-stale: #fbbf24;

  /* "Assets" button map markers -- deliberately not any of the above
     colors, so a location marker never reads as a character/security dot. */
  --asset-marker: #eab308;

  /* Base HSL character-marker hue is derived per-character (a deterministic
     hash of character_id) in map.js -- these two control the shared
     saturation/lightness so every marker still reads as one palette family. */
  --char-marker-saturation: 85%;
  --char-marker-lightness: 65%;

  --panel-notch: 14px;
  --chrome-notch: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
}

#map-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
}

#map-canvas canvas {
  display: block;
  touch-action: none;
}

.eve-panel {
  background: var(--panel-bg);
  background-image: linear-gradient(to bottom, rgba(56, 189, 248, 0.08), transparent 60px);
  border: 1px solid var(--panel-border-light);
  clip-path: polygon(
    var(--panel-notch) 0,
    100% 0,
    100% calc(100% - var(--panel-notch)),
    calc(100% - var(--panel-notch)) 100%,
    0 100%,
    0 var(--panel-notch)
  );
}

button,
.button {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border-light);
  color: var(--text);
  font: inherit;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.75rem;
  padding: 0.5em 0.9em;
  cursor: pointer;
  clip-path: polygon(
    var(--chrome-notch) 0,
    100% 0,
    100% calc(100% - var(--chrome-notch)),
    calc(100% - var(--chrome-notch)) 100%,
    0 100%,
    0 var(--chrome-notch)
  );
}

button:hover,
.button:hover {
  border-color: var(--accent);
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.35);
}

button:disabled,
.button:disabled {
  opacity: 0.5;
  cursor: default;
  box-shadow: none;
}

.button--primary {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: #04121c;
  font-weight: 600;
}

.button--danger {
  color: var(--danger);
  width: 100%;
  margin-top: 0.5rem;
}

.button--danger:hover {
  border-color: var(--danger);
  box-shadow: 0 0 8px rgba(248, 113, 113, 0.35);
}

input[type="text"],
input[type="search"] {
  background: var(--bg);
  border: 1px solid var(--panel-border-light);
  color: var(--text);
  font: inherit;
  padding: 0.5em 0.7em;
}

input[type="text"]:focus,
input[type="search"]:focus {
  outline: 1px solid var(--accent);
}

/* ---- Layout shell ---- */

#topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 1rem;
  pointer-events: none;
}

#topbar > * {
  pointer-events: auto;
}

#breadcrumb {
  font-size: 0.85rem;
  color: var(--text-dim);
  padding: 0.4rem 0.8rem;
}

#breadcrumb button {
  background: none;
  border: none;
  color: var(--accent);
  clip-path: none;
  padding: 0 0.2em;
  text-transform: none;
  letter-spacing: normal;
  font-size: inherit;
}

#breadcrumb button:hover {
  text-decoration: underline;
  box-shadow: none;
}

#search-box {
  flex: 0 0 auto;
  position: relative;
}

#search-input {
  width: 220px;
}

#search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 320px;
  max-height: 360px;
  overflow-y: auto;
  padding: 0.4rem 0;
  display: none;
}

#search-results.open {
  display: block;
}

.search-result {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.8rem;
  cursor: pointer;
  font-size: 0.85rem;
}

.search-result:hover {
  background: rgba(56, 189, 248, 0.12);
}

.search-result .kind {
  color: var(--text-dim);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex: none;
}

.search-result .location {
  display: block;
  color: var(--text-dim);
  font-size: 0.7rem;
}

#account-controls {
  margin-left: auto;
  display: flex;
  gap: 0.5rem;
}

#map-controls {
  position: fixed;
  bottom: 1rem;
  left: 1rem;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

#map-controls .row {
  display: flex;
  gap: 0.4rem;
}

#character-panel {
  position: fixed;
  top: 4rem;
  right: 1rem;
  z-index: 10;
  width: 260px;
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
  padding: 0.8rem;
  font-size: 0.85rem;
}

#character-panel h2 {
  margin: 0 0 0.6rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

/* Minimized via the "Characters" map control -- collapses down to just the
   heading, hiding the online-only toggle and the list underneath it. */
#character-panel.collapsed {
  max-height: none;
  overflow: visible;
}

#character-panel.collapsed h2 {
  margin-bottom: 0;
}

#character-panel.collapsed .character-row {
  display: none;
}

.character-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0;
  cursor: pointer;
}

.character-row .swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
}

.character-row .status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
  margin-left: auto;
}

.character-row .info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.character-row .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.character-row .location {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-dim);
  font-size: 0.75rem;
}

/* Pull-tab for the mobile drawer (see the mobile media query below) --
   hidden on desktop, where the panel is never off-screen to begin with. */
#character-panel-handle {
  display: none;
  position: fixed;
  top: 50%;
  right: 0;
  z-index: 11;
  transform: translateY(-50%);
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 3.2rem;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
  color: var(--accent);
  border-right: none;
  clip-path: none;
}

/* Shared footprint for every popup surface (the character/system/region
   detail card, and the assets/contracts lightboxes) so they all read as
   one consistent size regardless of where/how each is triggered -- only
   position and open/close mechanics differ per element. */
.popup-panel {
  width: min(420px, 100%);
  max-height: 70vh;
  overflow-y: auto;
  padding: 0.9rem 1rem;
}

.popup-panel h2 {
  margin: 0 0 0.3rem;
  font-size: 1rem;
  padding-right: 1.5rem;
}

.popup-panel .close {
  position: absolute;
  top: 0.4rem;
  right: 0.5rem;
  background: none;
  border: none;
  color: var(--text-dim);
  clip-path: none;
  padding: 0.2rem 0.5rem;
}

#info-panel {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 10;
  display: none;
}

#info-panel.open {
  display: block;
}

.character-header {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 0.6rem;
}

.character-header h2 {
  margin: 0;
}

.character-header .subtitle {
  margin-bottom: 0;
}

.character-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

.character-actions .button {
  flex: 1;
}

.character-header .portrait {
  width: 64px;
  height: 64px;
  flex: none;
  border-radius: 4px;
  border: 1px solid var(--panel-border-light);
}

.character-header {
  cursor: pointer;
}

.character-header:hover .portrait {
  border-color: var(--accent);
}

.character-header:hover h2 {
  color: var(--accent);
}

#info-panel .subtitle {
  color: var(--text-dim);
  font-size: 0.75rem;
  margin-bottom: 0.6rem;
}

#info-panel dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 0.6rem;
  margin: 0;
  font-size: 0.8rem;
}

#info-panel dt {
  color: var(--text-dim);
}

#info-panel dd {
  margin: 0;
}

/* ---- Assets/contracts lightboxes ---- */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(2, 6, 15, 0.7);
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.open {
  display: flex;
}

#assets-modal-panel,
#contracts-modal-panel {
  position: relative;
}

.asset-location {
  border-bottom: 1px solid var(--panel-border);
}

.asset-location-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.2rem;
  cursor: pointer;
  font-size: 0.85rem;
}

.asset-location-header:hover {
  color: var(--accent);
}

.asset-location-header .jumps {
  flex: none;
  color: var(--text-dim);
  font-size: 0.75rem;
}

.asset-location-header.expanded .jumps {
  color: var(--accent);
}

.asset-location-items {
  padding: 0 0.2rem 0.6rem;
}

.asset-item {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.2rem 0;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.contracts-modal-filters {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
}

.contracts-filter.active {
  border-color: var(--accent);
  color: var(--accent);
}

.contract-row {
  border-bottom: 1px solid var(--panel-border);
}

.contract-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.2rem;
  cursor: pointer;
  font-size: 0.85rem;
}

.contract-header:hover {
  color: var(--accent);
}

.contract-header .title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contract-header .amount {
  flex: none;
  color: var(--text-dim);
  font-size: 0.75rem;
}

.contract-header.expanded .amount {
  color: var(--accent);
}

.contract-detail {
  padding: 0 0.2rem 0.6rem;
  font-size: 0.8rem;
}

.contract-detail dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.2rem 0.6rem;
  margin: 0 0 0.4rem;
}

.contract-detail dt {
  color: var(--text-dim);
}

.contract-detail dd {
  margin: 0;
}

.contract-item {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.15rem 0;
  color: var(--text-dim);
}

/* ---- Skills lightbox ---- */

.skills-section-heading {
  margin: 0.9rem 0 0.3rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}

.skills-section-heading:first-child {
  margin-top: 0;
}

.skill-queue-row {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.3rem 0.2rem;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--panel-border);
}

.skill-queue-row .eta {
  flex: none;
  color: var(--text-dim);
  font-size: 0.75rem;
}

.skill-group {
  border-bottom: 1px solid var(--panel-border);
}

.skill-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.2rem;
  cursor: pointer;
  font-size: 0.85rem;
}

.skill-group-header:hover {
  color: var(--accent);
}

.skill-group-header .count {
  flex: none;
  color: var(--text-dim);
  font-size: 0.75rem;
}

.skill-group-header.expanded .count {
  color: var(--accent);
}

.skill-group-items {
  padding: 0 0.2rem 0.5rem;
}

.skill-row {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.18rem 0;
  font-size: 0.8rem;
}

.skill-row .level {
  flex: none;
  width: 2em;
  color: var(--accent);
  font-weight: 600;
}

.skill-row .name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.skill-row .sp {
  flex: none;
  color: var(--text-dim);
}

/* ---- First-visit guide ---- */

.guide-text {
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.5;
  margin: 0 0 0.7rem;
}

.guide-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-top: 0.8rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--panel-border);
}

.guide-checkbox {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-dim);
  cursor: pointer;
}

.guide-legal {
  margin: 0.7rem 0 0;
  font-size: 0.68rem;
  line-height: 1.5;
  color: var(--text-dim);
  opacity: 0.75;
}

#nav-toggle {
  display: none;
}

/* Persistent trademark/copyright strip -- kept legible but out of the way
   at the very bottom edge, below map-controls' own 1rem gap from the
   bottom (see #map-controls), so it never overlaps those buttons. */
#site-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  padding: 0.15rem 0.5rem;
  text-align: center;
  font-size: 0.65rem;
  line-height: 1.4;
  color: var(--text-dim);
  opacity: 0.65;
  background: rgba(11, 17, 32, 0.55);
  pointer-events: none;
}

#site-footer a {
  color: inherit;
  pointer-events: auto;
}

#site-footer a:hover {
  color: var(--accent);
}

/* ---- Mobile / tablet ---- */
@media (max-width: 640px) {
  #topbar {
    flex-wrap: wrap;
  }

  #search-input {
    width: 100%;
  }

  #search-box {
    order: 3;
    flex: 1 1 100%;
  }

  #account-controls {
    margin-left: 0;
  }

  /* Off-canvas drawer instead of a bottom strip -- on a phone-sized
     viewport the character list would otherwise cover most of the map.
     It slides in from the right edge; panels.js starts it collapsed on
     these viewports and the pull-tab (#character-panel-handle) toggles it
     the same way the desktop "Characters" map-control button does. */
  #character-panel {
    top: 4rem;
    bottom: auto;
    right: 0;
    left: auto;
    width: 78vw;
    max-width: 300px;
    max-height: calc(100vh - 6rem);
    transition: transform 0.25s ease;
  }

  #character-panel.collapsed {
    transform: translateX(100%);
  }

  #character-panel-handle {
    display: flex;
  }

  #info-panel {
    left: 0.5rem;
    right: 0.5rem;
    width: auto;
    bottom: 0.5rem;
  }

  #map-controls {
    bottom: 0.5rem;
    left: 0.5rem;
  }

  /* Too little room on a phone screen for this alongside the map controls
     and character panel -- still reachable via the "?" guide's own legal
     notice and the /terms, /privacy pages themselves. */
  #site-footer {
    display: none;
  }
}
