/* App 05 - Cat Nat Wave Visualiser */

:root {
  --ink: #111111;
  --paper: #f9f9f9;
  --surface: #ffffff;
  --surface-soft: #f6f4f1;
  --border: rgba(17, 17, 17, .10);
  --border-strong: rgba(249, 115, 22, .26);
  --orange: var(--primary-color, #EAB308);
  --gold: #c88728;
  --dim: #6b6b6b;
  --muted: #9ca3af;
  --f-ui: var(--font-primary, 'Inter', sans-serif);
  --f-serif: var(--font-heading, 'Playfair Display', serif);
  --f-mono: 'DM Mono', monospace;
  --r: 14px;
  --shadow-sm: 0 8px 24px rgba(0, 0, 0, .07);
  --shadow-lg: 0 24px 70px rgba(17, 17, 17, .18);
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  background: #050505;
  color: var(--ink);
  font-family: var(--f-ui);
  font-size: 14px;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(255, 255, 255, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, .65), transparent 62%);
  z-index: 0;
}

.topnav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 700;
  height: 68px;
  display: flex;
  align-items: center;
  gap: 1.1rem;
  padding: 0 1.5rem;
  background: rgba(17, 17, 17, .93);
  border-bottom: 1px solid rgba(255, 255, 255, .09);
  box-shadow: 0 12px 36px rgba(0, 0, 0, .16);
  backdrop-filter: blur(14px);
}

.topnav-back,
.topnav-app,
.topnav-tag,
.usage-label {
  color: rgba(255, 255, 255, .72);
  line-height: 1;
}

.topnav-back {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font-family: var(--f-mono);
  font-size: .68rem;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.topnav-back:hover,
.topnav-app {
  color: #fff;
}

.topnav-sep {
  width: 1px;
  height: 22px;
  background: rgba(255, 255, 255, .13);
}

.topnav-app {
  font-family: var(--f-ui);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: .01em;
}

.topnav-tag {
  padding: .38rem .78rem;
  border: 1px solid rgba(249, 115, 22, .38);
  border-radius: 999px;
  background: rgba(249, 115, 22, .13);
  color: #FEF08A;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.topnav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: .85rem;
}

.usage-chips {
  display: flex;
  gap: 4px;
}

.chip {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, .13);
}

.chip.empty {
  background: rgba(255, 255, 255, .20);
  box-shadow: none;
}

.usage-label {
  font-family: var(--f-mono);
  font-size: .68rem;
  letter-spacing: .06em;
}

.layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(320px, 365px) 1fr;
  height: calc(100vh - 68px);
  margin-top: 68px;
  padding: 16px;
  gap: 16px;
}

.sidebar {
  position: relative;
  z-index: 20;
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 20px;
  background: rgba(8, 8, 8, .92);
  box-shadow: none;
  backdrop-filter: blur(16px);
}

.sidebar-block {
  padding: 1.15rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.sidebar-block:last-child {
  border-bottom: 0;
}

.blk-label,
.leg-title,
.wi-lbl {
  margin-bottom: .85rem;
  color: var(--muted);
  font-family: var(--f-mono);
  font-size: .64rem;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.sidebar .blk-label,
.sidebar .wi-lbl {
  color: rgba(255, 255, 255, .42);
}

.peril-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .6rem;
}

.peril-tab {
  min-height: 86px;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 16px;
  background: rgba(255, 255, 255, .035);
  color: rgba(255, 255, 255, .62);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: .28rem;
  font: 700 .82rem/1 var(--f-ui);
  box-shadow: none;
  transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease, color .2s ease;
}

.peril-tab:hover {
  border-color: rgba(249, 115, 22, .36);
  color: #fff;
  transform: translateY(-1px);
}

.peril-tab.on {
  border-color: transparent;
  background: var(--gradient-1);
  color: #fff;
  box-shadow: 0 12px 28px rgba(249, 115, 22, .28);
}

.peril-tab .ico {
  font-size: 1.45rem;
  line-height: 1;
}

.tag-speed {
  color: rgba(255, 255, 255, .72);
  font-family: var(--f-mono);
  font-size: .58rem;
  font-weight: 400;
}

.peril-tab:not(.on) .tag-speed {
  color: rgba(255, 255, 255, .34);
}

.click-hint {
  display: flex;
  align-items: center;
  gap: .62rem;
  padding: .25rem 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: rgba(255, 255, 255, .68);
  font-size: .78rem;
  font-weight: 600;
}

.pulse-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 0 0 rgba(249, 115, 22, .38);
  animation: pulse-anim 1.5s ease-out infinite;
  flex: 0 0 auto;
}

@keyframes pulse-anim {
  70% { box-shadow: 0 0 0 12px rgba(249, 115, 22, 0); }
  100% { box-shadow: 0 0 0 0 rgba(249, 115, 22, 0); }
}

.field {
  margin-bottom: .85rem;
}

.field:last-child {
  margin-bottom: 0;
}

.field-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: .75rem;
  margin-bottom: .38rem;
  color: rgba(255, 255, 255, .68);
  font-family: var(--f-mono);
  font-size: .68rem;
  letter-spacing: .04em;
}

.field-hint {
  color: rgba(255, 255, 255, .34);
  white-space: nowrap;
}

.inp-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .55rem;
}

.inp {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 12px;
  background: rgba(255, 255, 255, .04);
  color: rgba(255, 255, 255, .82);
  font-family: var(--f-mono);
  font-size: .78rem;
  outline: none;
  padding: .62rem .8rem;
  transition: border-color .18s ease, box-shadow .18s ease;
}

.inp:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 4px rgba(249, 115, 22, .12);
}

.inp.readonly {
  background: rgba(249, 115, 22, .06);
  color: #A16207;
}

.peril-select {
  color-scheme: dark;
  border-color: rgba(255, 255, 255, .08);
  background: rgba(255, 255, 255, .04);
  color: rgba(255, 255, 255, .82);
}

.parameter-header,
.mechanics-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 82px;
  gap: .65rem;
  padding: 0 0 .35rem;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.mechanics-header {
  grid-template-columns: minmax(0, 1fr) minmax(86px, .9fr);
}

.parameter-header span,
.mechanics-header span {
  color: rgba(255, 255, 255, .34);
  font-family: var(--f-mono);
  font-size: .55rem;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.parameter-header span:last-child,
.mechanics-header span:last-child {
  text-align: center;
}

.parameter-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 82px;
  align-items: center;
  gap: .65rem;
  padding: .34rem 0;
}

.parameter-label {
  min-width: 0;
  color: rgba(255, 255, 255, .68);
  font-family: var(--f-mono);
  font-size: .66rem;
  line-height: 1.35;
}

.parameter-label .field-hint {
  color: rgba(255, 255, 255, .34);
  font-size: .58rem;
  white-space: nowrap;
}

.parameter-inp {
  min-height: 28px;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: .12rem 0;
  text-align: center;
}

.parameter-inp:focus {
  box-shadow: inset 0 -1px 0 rgba(249, 115, 22, .65);
}

.parameter-inp.readonly {
  background: transparent;
  color: #FACC15;
}

.sidebar input[type="number"] {
  color-scheme: dark;
}

.sidebar input[type="number"]::-webkit-outer-spin-button,
.sidebar input[type="number"]::-webkit-inner-spin-button {
  opacity: .32;
  filter: invert(1) grayscale(1);
}

.sidebar input[type="number"]:hover::-webkit-outer-spin-button,
.sidebar input[type="number"]:hover::-webkit-inner-spin-button,
.sidebar input[type="number"]:focus::-webkit-outer-spin-button,
.sidebar input[type="number"]:focus::-webkit-inner-spin-button {
  opacity: .52;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: .78rem;
}

.time-display {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .2rem .55rem;
  align-items: baseline;
  padding: 0 0 .55rem;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  border-radius: 0;
  background: transparent;
}

.time-val {
  color: #fff;
  font-family: var(--f-ui);
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1;
}

.time-unit {
  color: rgba(255, 255, 255, .62);
  font-family: var(--f-ui);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .02em;
}

.time-radius {
  grid-column: 1 / -1;
  color: #A16207;
  font-family: var(--f-mono);
  font-size: .72rem;
}

.play-row {
  display: flex;
  gap: .65rem;
}

.play-btn,
.reset-btn,
.pro-go {
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  font-family: var(--f-ui);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  transition: box-shadow .2s ease, transform .2s ease, background .2s ease;
}

.play-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  min-height: 44px;
  background: var(--gradient-1);
  color: #fff;
  box-shadow: none;
}

.play-btn:hover,
.pro-go:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(249, 115, 22, .34);
}

.reset-btn {
  min-height: 44px;
  padding: 0 .95rem;
  border: 1px solid rgba(255, 255, 255, .08);
  background: rgba(255, 255, 255, .035);
  color: rgba(255, 255, 255, .62);
}

.reset-btn:hover {
  color: #fff;
  border-color: rgba(249, 115, 22, .35);
}

.slider-row {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.slider-lbl,
.speed-val {
  color: rgba(255, 255, 255, .62);
  font-family: var(--f-mono);
  font-size: .66rem;
  white-space: nowrap;
}

.speed-val {
  width: 2rem;
  color: #A16207;
  text-align: right;
}

input[type="range"] {
  flex: 1;
  appearance: none;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .12);
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 3px 12px rgba(249, 115, 22, .45);
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: 50%;
  background: var(--orange);
}

.wave-info {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.wi-lbl {
  color: #A16207;
}

.wi-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(86px, .9fr);
  align-items: baseline;
  gap: .75rem;
  margin-bottom: 0;
  padding: .34rem 0;
}

.wi-key,
.wi-val,
.wi-formula,
.book-ref {
  font-family: var(--f-mono);
}

.wi-key {
  color: rgba(255, 255, 255, .62);
  font-size: .68rem;
}

.wi-val {
  color: rgba(255, 255, 255, .82);
  font-size: .72rem;
  font-weight: 500;
  text-align: center;
}

.wi-formula {
  margin-top: .45rem;
  color: rgba(255, 255, 255, .48);
  font-size: .76rem;
  line-height: 1.6;
  text-align: center;
}

.book-ref {
  color: rgba(255, 255, 255, .42);
  font-size: .64rem;
  line-height: 1.7;
}

.ref-title {
  color: #FACC15;
}

.map-wrap {
  position: relative;
  overflow: hidden;
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, .74);
  border-radius: 22px;
  background: #e8ecea;
  box-shadow: var(--shadow-lg);
}

#map {
  width: 100%;
  height: 100%;
  background: #edf0ed;
}

#waveCanvas {
  position: absolute;
  inset: 0;
  z-index: 400;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.legend {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 500;
  min-width: 230px;
  padding: 1rem 1.05rem;
  border: 1px solid rgba(255, 255, 255, .72);
  border-radius: 18px;
  background: rgba(255, 255, 255, .88);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .10);
  backdrop-filter: blur(14px);
}

.leg-title {
  margin-bottom: .75rem;
}

.leg-row {
  display: flex;
  align-items: center;
  gap: .68rem;
  margin-bottom: .5rem;
}

.leg-row:last-child {
  margin-bottom: 0;
}

.leg-line {
  flex: 0 0 auto;
  width: 26px;
  height: 3px;
  border-radius: 99px;
}

.leg-label {
  color: var(--dim);
  font-family: var(--f-mono);
  font-size: .68rem;
  line-height: 1.35;
}

.leg-label strong {
  color: var(--ink);
  font-weight: 600;
}

.map-badge {
  position: absolute;
  left: 16px;
  bottom: 16px;
  z-index: 500;
  padding: .45rem .72rem;
  border: 1px solid rgba(255, 255, 255, .72);
  border-radius: 999px;
  background: rgba(255, 255, 255, .86);
  color: var(--dim);
  font-family: var(--f-mono);
  font-size: .6rem;
  letter-spacing: .04em;
  backdrop-filter: blur(12px);
}

.leaflet-control-zoom {
  border: 0 !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12) !important;
}

.leaflet-control-zoom a {
  border: 0 !important;
  color: var(--ink) !important;
  font-family: var(--f-ui) !important;
  font-weight: 800;
}

.src-popup .leaflet-popup-content-wrapper {
  border-radius: 14px;
  background: #111;
  color: #fff;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .26);
}

.src-popup .leaflet-popup-tip {
  background: #111;
}

.src-popup .leaflet-popup-content {
  margin: .75rem .9rem;
  font-family: var(--f-mono);
  font-size: .72rem;
}

.pro-veil {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 900;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(17, 17, 17, .36);
  backdrop-filter: blur(10px);
}

.pro-veil.show {
  display: flex;
}

.pro-card {
  width: min(430px, 100%);
  padding: 2.2rem;
  border-radius: 22px;
  background: #111;
  color: #fff;
  text-align: center;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .36);
}

.pro-ico {
  margin-bottom: 1rem;
  font-size: 2.2rem;
}

.pro-h {
  margin-bottom: .65rem;
  font-family: var(--f-serif);
  font-size: 2rem;
  font-weight: 700;
}

.pro-p {
  margin-bottom: 1.45rem;
  color: rgba(255, 255, 255, .68);
  font-size: .92rem;
  line-height: 1.7;
}

.pro-go {
  width: 100%;
  min-height: 46px;
  background: var(--gradient-1);
  color: #fff;
}

.pro-skip {
  display: inline-block;
  margin-top: 1rem;
  color: rgba(255, 255, 255, .48);
  cursor: pointer;
  font-family: var(--f-mono);
  font-size: .68rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.pro-skip:hover {
  color: rgba(255, 255, 255, .78);
}

@media (max-width: 980px) {
  html,
  body {
    overflow: auto;
  }

  .topnav {
    height: auto;
    min-height: 68px;
    flex-wrap: wrap;
    padding: .8rem 1rem;
    gap: .75rem;
  }

  .topnav-right {
    width: 100%;
    margin-left: 0;
    justify-content: flex-end;
  }

  .layout {
    grid-template-columns: 1fr;
    height: auto;
    min-height: calc(100vh - 68px);
    margin-top: 92px;
  }

  .sidebar {
    max-height: none;
  }

  .map-wrap {
    height: 62vh;
    min-height: 480px;
  }
}

@media (max-width: 620px) {
  .topnav-sep,
  .topnav-tag {
    display: none;
  }

  .topnav-app {
    font-size: 1rem;
  }

  .layout {
    padding: 10px;
    gap: 10px;
    margin-top: 108px;
  }

  .peril-tabs,
  .inp-row {
    grid-template-columns: 1fr;
  }

  .legend {
    left: 12px;
    right: 12px;
    top: 12px;
    min-width: 0;
  }

  .map-wrap {
    min-height: 420px;
  }
}
