/* transit-return.css */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f2f5;
  color: #1a1a1a;
  min-height: 100vh;
}

/* ── Header ── */
header {
  background: #1a1a2e;
  color: white;
  padding: 1.25rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.back-btn {
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: color 0.15s;
  flex-shrink: 0;
}
.back-btn:hover { color: white; }

.header-auth {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
  font-size: 0.82rem;
}

.header-auth-email {
  color: rgba(255,255,255,0.7);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-auth a, .header-auth button {
  color: rgba(255,255,255,0.85);
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 4px;
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s;
}
.header-auth a:hover, .header-auth button:hover { background: rgba(255,255,255,0.22); }

header h1 {
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ── Layout ── */
main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ── Card ── */
.card {
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 8px rgba(0,0,0,0.04);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
}

.card-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #888;
  margin-bottom: 1.25rem;
  font-weight: 600;
}

/* ── Form ── */
.field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  color: #444;
  margin-bottom: 0.35rem;
}

select, input[type="date"] {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid #d5d5d5;
  border-radius: 5px;
  font-size: 0.9rem;
  color: #1a1a1a;
  background: white;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: auto;
  -webkit-appearance: auto;
}

select:focus, input[type="date"]:focus {
  outline: none;
  border-color: #4a6fa5;
  box-shadow: 0 0 0 3px rgba(74,111,165,0.14);
}

#chartSelect {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: end;
}

#calcBtn {
  background: #4a6fa5;
  color: white;
  border: none;
  padding: 0.55rem 1.25rem;
  border-radius: 5px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
#calcBtn:hover  { background: #3a5a8a; }
#calcBtn:disabled { background: #aaa; cursor: default; }

#fromDateField {
  margin-top: 0.75rem;
}

#calcStatus {
  margin-top: 0.75rem;
  font-size: 0.84rem;
  color: #555;
  min-height: 1.2em;
}
#calcStatus.error { color: #a52020; }

/* ── Lock Overlay ── */
#lockOverlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(240,242,245,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
}

.lock-card {
  background: white;
  border-radius: 12px;
  padding: 2.5rem 2rem;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,0.2);
  max-width: 420px;
  width: 90%;
}
.lock-icon  { font-size: 2.5rem; margin-bottom: 1rem; }
.lock-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.5rem; color: #1a1a2e; }
.lock-body  { font-size: 0.88rem; color: #555; margin-bottom: 1.5rem; line-height: 1.6; }
.lock-btn-sub {
  display: inline-block;
  background: #2e7d32;
  color: white;
  padding: 0.65rem 1.75rem;
  border-radius: 5px;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
}
.lock-hint { margin-top: 0.85rem; font-size: 0.82rem; color: #aaa; }

/* ── Mode Tabs ── */
.mode-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.mode-tab {
  padding: 0.4rem 0.9rem;
  border: 1px solid #d5d5d5;
  border-radius: 20px;
  font-size: 0.82rem;
  cursor: pointer;
  background: white;
  color: #555;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  white-space: nowrap;
}
.mode-tab:hover  { border-color: #4a6fa5; color: #4a6fa5; }
.mode-tab.active {
  background: #4a6fa5;
  border-color: #4a6fa5;
  color: white;
}
.mode-tab.active.opp {
  background: #7b3f9c;
  border-color: #7b3f9c;
}
.mode-tab.opp:hover { border-color: #7b3f9c; color: #7b3f9c; }

/* ── Results Table ── */
.return-table-wrap { overflow-x: auto; }

#returnTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

#returnTable thead th {
  padding: 0.4rem 0.75rem;
  border-bottom: 2px solid #e8e8e8;
  white-space: nowrap;
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #888;
  font-weight: 600;
}
#returnTable thead th.col-p { color: #1a1a2e; }
#returnTable thead th.col-d { color: #8b0000; }

#returnTable tbody tr:nth-child(even) { background: #fafafa; }
#returnTable tbody tr:hover           { background: #f0f4fa; }

#returnTable td {
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
  white-space: nowrap;
}

.rt-planet {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.rt-sym {
  width: 1.2rem;
  height: 1.2rem;
  color: #555;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.rt-sym svg { display: block; }
.rt-name { font-weight: 500; color: #333; }

.rt-date { font-size: 0.84rem; color: #222; }
.rt-gate { font-family: 'SF Mono', 'Consolas', 'Menlo', monospace; font-size: 0.82rem; color: #666; margin-top: 0.15rem; }
.rt-gate-p { color: #1a1a2e; font-weight: 600; }
.rt-gate-d { color: #8b0000; font-weight: 600; }

.col-planet { min-width: 110px; }
.col-p, .col-d { min-width: 160px; }

/* ── Clickable table cells ── */
#returnTable tbody td.col-p,
#returnTable tbody td.col-d { cursor: pointer; }
#returnTable tbody td.col-p:hover,
#returnTable tbody td.col-d:hover { background: #e8eef8 !important; }
#returnTable tbody tr.selected td { background: #eef3fb; }

/* ── Bodygraph grid (3 columns) ── */
.overlay-graphs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.overlay-graph-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 8px rgba(0,0,0,0.04);
  padding: 1rem 0.75rem 0.75rem;
}

.overlay-graph-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #888;
  font-weight: 600;
  margin-bottom: 0.65rem;
  text-align: center;
}

#bg-natal svg,
#bg-composite svg,
#bg-return svg {
  width: 100%;
  height: auto;
  display: block;
}

/* ── Bodygraph planet sub-table ── */
.bg-planet-table {
  width: 100%;
  margin-top: 0.6rem;
  border-top: 1px solid #f0f0f0;
  padding-top: 0.4rem;
}

.bg-pt {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.76rem;
}

.bg-pt th {
  padding: 0.15rem 0.3rem;
  border-bottom: 1px solid #e8e8e8;
  text-align: center;
  font-size: 0.63rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #aaa;
  font-weight: 600;
}
.bg-pt th.bg-pt-th-p { color: #1a1a2e; }
.bg-pt th.bg-pt-th-d { color: #8b0000; }

.bg-pt td {
  padding: 0.15rem 0.3rem;
  border-bottom: 1px solid #f5f5f5;
  vertical-align: middle;
  white-space: nowrap;
}
.bg-pt tr:last-child td { border-bottom: none; }

.bg-pt-planet {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.bg-pt-sym {
  width: 1rem;
  height: 1rem;
  color: #555;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.bg-pt-sym svg { display: block; }
.bg-pt-name { color: #444; }

.bg-pt-p {
  text-align: center;
  font-family: 'SF Mono', 'Consolas', 'Menlo', monospace;
  font-weight: 600;
  color: #1a1a2e;
}
.bg-pt-d {
  text-align: center;
  font-family: 'SF Mono', 'Consolas', 'Menlo', monospace;
  font-weight: 600;
  color: #8b0000;
}
.bg-pt-retro    { color: #bbb; font-size: 0.68em; margin-left: 0.1rem; }
.bg-pt-ed       { font-size: 0.68em; font-weight: 700; margin-left: 0.1rem; }
.bg-pt-exalted  { color: #2e7d32; }
.bg-pt-detriment { color: #c75000; }

/* ── Bodygraph channel list (under composite) ── */
.bg-ch-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #aaa;
  font-weight: 600;
  margin-top: 0.6rem;
  margin-bottom: 0.25rem;
}
.bg-ch-label:first-child { margin-top: 0; }

.design-toggle-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem 0.25rem;
  font-size: 0.82rem;
  color: #555;
}

.design-toggle-row label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
}

.composite-type-badge {
  text-align: center;
  margin-top: 0.4rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #444;
  letter-spacing: 0.03em;
}

.bg-channels {
  width: 100%;
  margin-top: 0.6rem;
  border-top: 1px solid #f0f0f0;
  padding-top: 0.5rem;
  font-size: 0.78rem;
  line-height: 1.8;
}

.bg-channels .channel-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border-radius: 3px;
  padding: 0.05rem 0.2rem;
  font-size: 0.76rem;
  color: #555;
}
.bg-channels .center-dot {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  flex-shrink: 0;
}
.bg-channels .channel-sep { color: #ddd; }

/* ── Mode tab: history ── */
.mode-tab.hist { }
.mode-tab.hist.active {
  background: #2e7d32;
  border-color: #2e7d32;
}
.mode-tab.hist:hover { border-color: #2e7d32; color: #2e7d32; }

/* ── History controls ── */
.history-controls {
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem 1.25rem;
  flex-wrap: wrap;
}

.history-range {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.86rem;
  color: #555;
  flex-wrap: wrap;
}

.year-spinner {
  width: 72px;
  padding: 0.3rem 0.4rem;
  border: 1px solid #d5d5d5;
  border-radius: 5px;
  font-size: 0.86rem;
  color: #1a1a1a;
  text-align: center;
  -moz-appearance: textfield;
}
.year-spinner::-webkit-inner-spin-button,
.year-spinner::-webkit-outer-spin-button {
  opacity: 1;
}
.year-spinner:focus {
  outline: none;
  border-color: #4a6fa5;
  box-shadow: 0 0 0 3px rgba(74,111,165,0.14);
}

/* ── Legend ── */
.history-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin-bottom: 1rem;
  font-size: 0.78rem;
  color: #555;
  align-items: center;
}

.hl-legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  user-select: none;
}

.hl-legend-item input[type="checkbox"] {
  margin: 0;
  cursor: pointer;
  accent-color: #4a6fa5;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.hl-legend-item:not(:has(input)) {
  cursor: default;
}

/* Legend marker: same shape as lane markers */
.hl-lm {
  display: inline-block;
  flex-shrink: 0;
}
.hl-lm.ret-p { width: 10px; height: 9px; background: #1a1a2e; clip-path: polygon(50% 0%, 0% 100%, 100% 100%); }
.hl-lm.ret-d { width: 10px; height: 9px; background: #8b0000; clip-path: polygon(50% 0%, 0% 100%, 100% 100%); }
.hl-lm.opp-p { width: 10px; height: 9px; background: #7b3f9c; clip-path: polygon(0% 0%, 100% 0%, 50% 100%); }
.hl-lm.opp-d { width: 10px; height: 9px; background: #c75000; clip-path: polygon(0% 0%, 100% 0%, 50% 100%); }

/* ── Click hint ── */
.history-hint {
  font-size: 0.78rem;
  color: #aaa;
  font-style: italic;
  margin: 0.25rem 0 0.75rem;
}

/* ── Timeline wrapper (horizontal scroll) ── */
.history-timeline-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 0.5rem;
  padding-bottom: 0.75rem;
}

/* ── Grid: label col | timeline ── */
.hl-grid {
  display: grid;
  grid-template-columns: 110px 1fr;
  min-width: 680px;
}

/* Year axis */
.hl-label-col { /* empty corner */ }

.hl-axis {
  position: relative;
  height: 22px;
  border-left: 1px solid #ddd;
  margin-bottom: 6px;
}

.hl-year {
  position: absolute;
  font-size: 0.66rem;
  color: #bbb;
  transform: translateX(-50%);
  top: 4px;
  white-space: nowrap;
  pointer-events: none;
}

/* Planet label cell */
.hl-label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.78rem;
  color: #444;
  font-weight: 500;
  padding-right: 8px;
  min-height: 38px;
  border-bottom: 1px solid #f5f5f5;
  position: sticky;
  left: 0;
  background: white;
  z-index: 2;
}

.hl-label-col {
  position: sticky;
  left: 0;
  background: white;
  z-index: 2;
}

.hl-planet-name { cursor: pointer; }
.hl-planet-name:hover { color: #4a6fa5; }

/* Timeline lane */
.hl-lane {
  position: relative;
  min-height: 38px;
  border-left: 1px solid #ddd;
  border-bottom: 1px solid #f5f5f5;
}

.hl-lane-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: #f0f0f0;
  pointer-events: none;
}

/* ── Markers ── */
.hl-marker {
  position: absolute;
  width: 10px;
  height: 9px;
  cursor: pointer;
  transform: translateX(-50%);
  transition: filter 0.1s;
  touch-action: manipulation;
  z-index: 1;
}

.hl-marker:hover   { filter: brightness(1.4) drop-shadow(0 0 2px rgba(0,0,0,0.4)); z-index: 5; }
.hl-marker.selected { filter: brightness(1.6) drop-shadow(0 0 4px rgba(0,0,0,0.5)); z-index: 6; }

/* Returns (▲) — clip-path triangle pointing up */
.hl-marker.ret-p { background: #1a1a2e; clip-path: polygon(50% 0%, 0% 100%, 100% 100%); top: 3px; }
.hl-marker.ret-d { background: #8b0000; clip-path: polygon(50% 0%, 0% 100%, 100% 100%); top: 27px; }

/* Oppositions (▽) — clip-path triangle pointing down */
.hl-marker.opp-p { background: #7b3f9c; clip-path: polygon(0% 0%, 100% 0%, 50% 100%); top: 11px; }
.hl-marker.opp-d { background: #c75000; clip-path: polygon(0% 0%, 100% 0%, 50% 100%); top: 21px; }

/* Legend filter checkboxes */
#historyTimeline.hide-ret-p .hl-marker.ret-p { display: none; }
#historyTimeline.hide-ret-d .hl-marker.ret-d { display: none; }
#historyTimeline.hide-opp-p .hl-marker.opp-p { display: none; }
#historyTimeline.hide-opp-d .hl-marker.opp-d { display: none; }

/* ── Responsive ── */
@media (max-width: 900px) {
  header { padding: 0.9rem 1.25rem; }
  .form-row { grid-template-columns: 1fr; }
  #calcBtn { width: 100%; }
}

@media (max-width: 700px) {
  .overlay-graphs { grid-template-columns: 1fr; }
  .overlay-graph-col { max-width: 280px; width: 100%; margin: 0 auto; }
}

@media (max-width: 480px) {
  header { padding: 0.7rem 1rem; }
  main { padding: 1.25rem 1rem; }
  .card { padding: 1.25rem; }
  .col-p, .col-d { min-width: 130px; }
  #returnTable { font-size: 0.78rem; }
}
