/* FATHOM — instrument-panel UI over a living water column.
   Accent color follows the current depth zone via --accent (set from JS). */

:root {
  --accent: #5fd4c4;
  --ink: #dff2f5;
  --ink-dim: #8fb0bc;
  --panel: rgba(6, 18, 28, 0.82);
  --panel-edge: rgba(120, 200, 220, 0.14);
  --glass: rgba(10, 28, 42, 0.6);
  --bad: #e06a6a;
  --gold: #e8c97a;
  --font-ui: 'Space Grotesk', system-ui, sans-serif;
  --font-brand: 'Michroma', monospace;
}

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

html,
body {
  height: 100%;
  overflow: hidden;
  background: #02101c;
}

body {
  font-family: var(--font-ui);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

.num {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

#sea {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
}

#pressure-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 180px rgba(224, 90, 90, 0);
  transition: box-shadow 1.5s ease;
  z-index: 3;
}
#pressure-vignette.warn {
  box-shadow: inset 0 0 180px rgba(224, 90, 90, 0.28);
}

#app {
  position: relative;
  z-index: 4;
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* ── top bar ── */

#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px 10px;
}

#wordmark {
  font-family: var(--font-brand);
  font-size: 19px;
  letter-spacing: 0.22em;
  color: var(--ink);
  text-shadow: 0 0 18px rgba(95, 212, 196, 0.35);
  user-select: none;
}

.word-sub {
  display: block;
  font-family: var(--font-ui);
  font-size: 9.5px;
  letter-spacing: 0.34em;
  color: var(--ink-dim);
  margin-top: 3px;
}

#top-stats {
  display: flex;
  gap: 8px;
  align-items: center;
}

.pill {
  background: var(--glass);
  border: 1px solid var(--panel-edge);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  backdrop-filter: blur(6px);
}

#pill-research {
  color: var(--gold);
}

.iconbtn {
  background: var(--glass);
  border: 1px solid var(--panel-edge);
  color: var(--ink);
  border-radius: 999px;
  width: 34px;
  height: 34px;
  font-size: 15px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition:
    border-color 0.15s,
    transform 0.1s;
}
.iconbtn:hover {
  border-color: var(--accent);
}
.iconbtn:active {
  transform: scale(0.93);
}
.iconbtn.off {
  color: #50707c;
  text-decoration: line-through;
}

/* ── main layout ── */

main {
  flex: 1;
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  padding: 8px 20px 20px;
  gap: 18px;
  min-height: 0;
}

/* ── instrument readout (left) ── */

#readout {
  align-self: flex-start;
  margin-top: 4vh;
  padding: 22px 26px;
  background: linear-gradient(160deg, rgba(8, 22, 34, 0.72), rgba(5, 14, 24, 0.55));
  border: 1px solid var(--panel-edge);
  border-radius: 18px;
  backdrop-filter: blur(10px);
  min-width: 300px;
  user-select: none;
}

#zone-name {
  font-family: var(--font-brand);
  font-size: 11px;
  letter-spacing: 0.42em;
  color: var(--accent);
  transition: color 1.2s;
  text-shadow: 0 0 14px color-mix(in srgb, var(--accent) 50%, transparent);
}

#depth-wrap {
  margin: 6px 0 2px;
}

#depth-num {
  font-size: 58px;
  font-weight: 300;
  letter-spacing: 0.02em;
  line-height: 1;
}

#depth-unit {
  font-size: 22px;
  color: var(--ink-dim);
  margin-left: 6px;
}

#depth-sub {
  color: var(--ink-dim);
  font-size: 12.5px;
  margin-bottom: 12px;
}

#hull-wrap {
  margin-bottom: 14px;
}

#hull-bar {
  height: 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

#hull-fill {
  height: 100%;
  width: 0%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), #c46be0);
  transition: width 0.5s linear;
}
#hull-fill.danger {
  background: linear-gradient(90deg, #c46be0, var(--bad));
}

#hull-label {
  font-size: 11px;
  color: var(--ink-dim);
  margin-top: 5px;
  letter-spacing: 0.06em;
}

#data-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

#data-num {
  font-size: 26px;
  font-weight: 500;
  color: var(--accent);
  transition: color 1.2s;
}

#data-rate {
  font-size: 13px;
  color: var(--ink-dim);
}

#buff-line {
  margin-top: 10px;
  font-size: 12px;
  color: var(--gold);
  border: 1px dashed rgba(232, 201, 122, 0.4);
  border-radius: 8px;
  padding: 5px 9px;
  animation: buffpulse 2s infinite;
}

@keyframes buffpulse {
  50% {
    border-color: rgba(232, 201, 122, 0.9);
  }
}

#btn-resurface {
  margin-top: 16px;
  width: 100%;
  padding: 12px;
  font-family: var(--font-brand);
  font-size: 12px;
  letter-spacing: 0.18em;
  color: #06222c;
  background: linear-gradient(120deg, var(--accent), #9fe8dc);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 0 24px color-mix(in srgb, var(--accent) 45%, transparent);
  transition:
    transform 0.1s,
    box-shadow 0.3s;
}
#btn-resurface:hover {
  box-shadow: 0 0 36px color-mix(in srgb, var(--accent) 70%, transparent);
}
#btn-resurface:active {
  transform: scale(0.97);
}

#next-milestone {
  margin-top: 12px;
  font-size: 11.5px;
  color: var(--ink-dim);
  letter-spacing: 0.04em;
}

/* ── right panel ── */

#panel {
  width: 400px;
  max-width: 44vw;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 18px;
  backdrop-filter: blur(12px);
  overflow: hidden;
}

#tabs {
  display: flex;
  border-bottom: 1px solid var(--panel-edge);
}

.tabbtn {
  flex: 1;
  background: none;
  border: none;
  color: var(--ink-dim);
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.14em;
  padding: 13px 0 11px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition:
    color 0.15s,
    border-color 0.15s;
  position: relative;
}
.tabbtn:hover {
  color: var(--ink);
}
.tabbtn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.tabbtn em {
  font-style: normal;
  color: var(--gold);
  font-size: 8px;
  position: absolute;
  margin-left: 3px;
  margin-top: -2px;
}

.tab {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  scrollbar-width: thin;
  scrollbar-color: rgba(120, 200, 220, 0.25) transparent;
}

.hidden {
  display: none !important;
}

/* ── dive tab ── */

#charter-line {
  font-size: 12px;
  color: var(--gold);
  border: 1px solid rgba(232, 201, 122, 0.25);
  background: rgba(232, 201, 122, 0.06);
  border-radius: 9px;
  padding: 8px 11px;
  margin-bottom: 10px;
}

#buyrow {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 10px;
}

.buylabel {
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--ink-dim);
  margin-right: 2px;
}

.qtybtn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-edge);
  color: var(--ink-dim);
  font-family: var(--font-ui);
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 7px;
  padding: 5px 11px;
  cursor: pointer;
  transition: all 0.12s;
}
.qtybtn:hover {
  color: var(--ink);
}
.qtybtn.active {
  color: #06222c;
  background: var(--accent);
  border-color: var(--accent);
}
#autobuy-toggle.active {
  background: var(--gold);
  border-color: var(--gold);
}

.up-row {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 12px;
  text-align: left;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 11px 13px;
  margin-bottom: 8px;
  cursor: pointer;
  color: var(--ink);
  font-family: var(--font-ui);
  transition:
    border-color 0.12s,
    background 0.12s,
    transform 0.06s;
}
.up-row:hover:not(.cant) {
  border-color: var(--accent);
  background: rgba(95, 212, 196, 0.07);
}
.up-row:active:not(.cant) {
  transform: scale(0.985);
}
.up-row.cant {
  cursor: default;
  opacity: 0.55;
}
.up-row.flash {
  animation: buyflash 0.45s;
}

@keyframes buyflash {
  0% {
    background: rgba(95, 212, 196, 0.35);
  }
}

.up-icon {
  font-size: 19px;
  color: var(--accent);
  width: 26px;
  text-align: center;
  flex-shrink: 0;
}

.up-body {
  flex: 1;
  min-width: 0;
}

.up-name {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
}

.up-name .up-lvl {
  font-style: normal;
  color: var(--ink-dim);
  font-weight: 400;
  margin-left: 6px;
  font-size: 12px;
}

.up-desc {
  display: block;
  font-size: 11.5px;
  color: var(--ink-dim);
  margin-top: 2px;
}

.up-cost {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  flex-shrink: 0;
}
.up-row.cant .up-cost {
  color: var(--ink-dim);
}
.up-cost.gold {
  color: var(--gold);
}
.up-cost.maxed {
  color: var(--ink-dim);
  letter-spacing: 0.14em;
  font-size: 10px;
}

/* ── lab tab ── */

#lab-intro {
  font-size: 12px;
  color: var(--ink-dim);
  line-height: 1.5;
  padding: 4px 4px 12px;
}
#lab-intro .r {
  color: var(--gold);
}
#lab-intro b {
  color: var(--ink);
}

/* ── bestiary ── */

#bestiary-summary {
  font-size: 12px;
  color: var(--ink-dim);
  padding: 2px 4px 12px;
  line-height: 1.5;
}

.zone-sec {
  margin-bottom: 16px;
}

.zone-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--font-brand);
  font-size: 10px;
  letter-spacing: 0.3em;
  padding: 0 2px 8px;
}

.zone-count {
  font-family: var(--font-ui);
  letter-spacing: 0.05em;
  color: var(--ink-dim);
  font-size: 11px;
}
.zone-count.done {
  color: var(--gold);
}

.species-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 7px;
}

.sp-card {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 7px 4px 6px;
  text-align: center;
  cursor: pointer;
  transition:
    border-color 0.12s,
    background 0.12s;
}
.sp-card:hover {
  border-color: var(--panel-edge);
  background: rgba(255, 255, 255, 0.06);
}
.sp-card canvas {
  width: 56px;
  height: 36px;
  display: block;
  margin: 0 auto;
}
.sp-card .sp-name {
  font-size: 9.5px;
  line-height: 1.25;
  margin-top: 4px;
  color: var(--ink-dim);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.sp-card.known .sp-name {
  color: var(--ink);
}
.sp-card.unknown {
  opacity: 0.45;
}
.sp-card.mythic.known {
  border-color: rgba(224, 138, 255, 0.4);
  box-shadow: 0 0 14px rgba(224, 138, 255, 0.12) inset;
}

/* ── log ── */

#log-list {
  display: flex;
  flex-direction: column-reverse;
  gap: 7px;
}

.log-entry {
  font-size: 12px;
  line-height: 1.45;
  padding: 7px 10px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.03);
  border-left: 2px solid var(--panel-edge);
  animation: logfade 0.4s ease;
}

@keyframes logfade {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}

.log-entry .log-meta {
  color: var(--ink-dim);
  font-size: 10px;
  letter-spacing: 0.08em;
  display: block;
  margin-bottom: 1px;
}
.log-entry.species {
  border-left-color: var(--accent);
}
.log-entry.milestone {
  border-left-color: var(--gold);
}
.log-entry.zone {
  border-left-color: #c46be0;
}
.log-entry.phenom {
  border-left-color: #e8c97a;
}
.log-entry.system {
  border-left-color: #5aa7e0;
}

/* ── toasts ── */

#toasts {
  position: fixed;
  left: 20px;
  bottom: 20px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 9px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  padding: 10px 16px 10px 12px;
  backdrop-filter: blur(10px);
  animation:
    toastin 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2),
    toastout 0.5s ease 5s forwards;
  max-width: 340px;
}

.toast.gold {
  border-left-color: var(--gold);
}
.toast.zone {
  border-left-color: #c46be0;
}

@keyframes toastin {
  from {
    opacity: 0;
    transform: translateX(-24px);
  }
}

@keyframes toastout {
  to {
    opacity: 0;
    transform: translateY(8px);
  }
}

.toast canvas {
  width: 64px;
  height: 40px;
  flex-shrink: 0;
}

.toast .t-kicker {
  font-size: 9px;
  letter-spacing: 0.26em;
  display: block;
}

.toast .t-title {
  font-size: 14px;
  font-weight: 600;
  display: block;
}

.toast .t-sub {
  font-size: 11px;
  color: var(--ink-dim);
  display: block;
  margin-top: 1px;
}

/* ── modals ── */

#modal-root {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(2, 10, 18, 0.72);
  backdrop-filter: blur(7px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadein 0.25s;
}

@keyframes fadein {
  from {
    opacity: 0;
  }
}

.modal {
  width: min(560px, calc(100vw - 36px));
  max-height: min(82vh, 720px);
  overflow-y: auto;
  background: linear-gradient(165deg, rgba(10, 26, 40, 0.97), rgba(5, 14, 24, 0.97));
  border: 1px solid var(--panel-edge);
  border-radius: 20px;
  padding: 26px 28px;
  scrollbar-width: thin;
  animation: modalin 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}

@keyframes modalin {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
}

.modal h2 {
  font-family: var(--font-brand);
  font-size: 15px;
  letter-spacing: 0.24em;
  color: var(--accent);
  margin-bottom: 4px;
}

.modal .m-sub {
  color: var(--ink-dim);
  font-size: 13px;
  line-height: 1.55;
  margin-bottom: 16px;
}

.modal .m-body {
  font-size: 13.5px;
  line-height: 1.6;
}

.m-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  justify-content: flex-end;
}

.btn {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.04em;
  border-radius: 10px;
  padding: 10px 18px;
  cursor: pointer;
  border: 1px solid var(--panel-edge);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  transition:
    border-color 0.12s,
    transform 0.08s;
}
.btn:hover {
  border-color: var(--accent);
}
.btn:active {
  transform: scale(0.97);
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #06222c;
}
.btn.danger {
  border-color: rgba(224, 106, 106, 0.5);
  color: var(--bad);
}

.charter-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.charter-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-edge);
  border-radius: 13px;
  padding: 13px 12px;
  cursor: pointer;
  text-align: left;
  color: var(--ink);
  font-family: var(--font-ui);
  transition: all 0.13s;
}
.charter-card:hover {
  border-color: var(--gold);
  background: rgba(232, 201, 122, 0.07);
}
.charter-card.picked {
  border-color: var(--gold);
  background: rgba(232, 201, 122, 0.13);
  box-shadow: 0 0 18px rgba(232, 201, 122, 0.15);
}

.charter-card .c-name {
  font-size: 12.5px;
  font-weight: 700;
  display: block;
  color: var(--gold);
}

.charter-card .c-blurb {
  font-size: 11px;
  color: var(--ink-dim);
  display: block;
  margin: 4px 0 6px;
  font-style: italic;
}

.charter-card .c-fx {
  font-size: 11px;
  display: block;
  line-height: 1.5;
}

.report-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0 4px;
}

.report-stat {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 11px;
  padding: 11px 13px;
}

.report-stat .rs-label {
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--ink-dim);
  display: block;
}

.report-stat .rs-val {
  font-size: 19px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  display: block;
  margin-top: 3px;
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 2px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 13.5px;
  gap: 14px;
}

.settings-row .s-hint {
  display: block;
  font-size: 11px;
  color: var(--ink-dim);
  margin-top: 2px;
}

.settings-row input[type='text'],
.settings-row select,
textarea.savefield {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--panel-edge);
  color: var(--ink);
  border-radius: 8px;
  padding: 7px 10px;
  font-family: var(--font-ui);
  font-size: 12.5px;
}

textarea.savefield {
  width: 100%;
  height: 74px;
  resize: none;
  margin-top: 8px;
  font-size: 10.5px;
  word-break: break-all;
}

.vault-code {
  font-family: var(--font-brand);
  letter-spacing: 0.34em;
  color: var(--accent);
  font-size: 17px;
}

.sp-detail {
  display: flex;
  gap: 18px;
  align-items: center;
}
.sp-detail canvas {
  width: 150px;
  height: 96px;
  flex-shrink: 0;
}

.rarity-tag {
  font-size: 9.5px;
  letter-spacing: 0.24em;
  font-weight: 700;
}

/* ── mobile ── */

@media (max-width: 860px) {
  main {
    flex-direction: column;
    padding: 4px 12px 12px;
    gap: 10px;
    overflow: hidden;
  }
  #readout {
    margin-top: 0;
    padding: 14px 18px;
    min-width: 0;
  }
  #depth-num {
    font-size: 40px;
  }
  #panel {
    width: 100%;
    max-width: none;
    flex: 1;
    min-height: 0;
  }
  .charter-grid {
    grid-template-columns: 1fr;
  }
  #wordmark {
    font-size: 15px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
