/* ===== RESET & BASE ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0e0e0e;
  --card: #1a1a1a;
  --card-alt: #222222;
  --text: #ffffff;
  --text-secondary: #b3b3b3;
  --text-muted: #777777;
  --green: #00c896;
  --red: #ff4d4f;
  --border: #2a2a2a;
  --radius: 10px;
  --max-w: 900px;
}

html { scroll-behavior: smooth; }

body {
  font-family: Inter, system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ===== NAV ===== */
nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(14,14,14,.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
}

.logo {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -.02em;
}

.logo span { color: var(--green); }

.nav-links { display: flex; gap: 24px; list-style: none; }

.nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: .875rem;
  font-weight: 500;
  transition: color .15s;
}

.nav-links a:hover,
.nav-links a.active { color: var(--text); }

.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.5rem;
  cursor: pointer;
}

/* ===== LAYOUT ===== */
.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 40px 20px 80px;
}

/* ===== HERO ===== */
.hero {
  text-align: center;
  padding: 60px 20px 40px;
}

.hero h1 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -.03em;
  margin-bottom: 12px;
}

.hero p {
  color: var(--text-secondary);
  font-size: 1.1rem;
  max-width: 520px;
  margin: 0 auto;
}

/* ===== PAGE HEADER ===== */
.page-header {
  margin-bottom: 32px;
}

.page-header h1 {
  font-size: clamp(1.6rem, 3.5vw, 2.2rem);
  font-weight: 700;
  letter-spacing: -.03em;
  margin-bottom: 8px;
}

.page-header p {
  color: var(--text-secondary);
  font-size: 1rem;
}

/* ===== CARDS ===== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

.card h2 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 20px;
  letter-spacing: -.02em;
}

/* ===== CALC GRID ===== */
.calc-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.calc-inputs,
.calc-outputs { min-width: 0; }

/* ===== FORM ===== */
.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.field input,
.field select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  padding: 12px 14px;
  outline: none;
  transition: border-color .15s;
  font-family: inherit;
}

.field input:focus,
.field select:focus {
  border-color: var(--green);
}

.field input::placeholder { color: var(--text-muted); }

/* Toggle */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.toggle-row label {
  font-size: .85rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.toggle {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle .slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 22px;
  cursor: pointer;
  transition: background .2s;
}

.toggle .slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  bottom: 3px;
  background: var(--text);
  border-radius: 50%;
  transition: transform .2s;
}

.toggle input:checked + .slider { background: var(--green); }
.toggle input:checked + .slider::before { transform: translateX(18px); }

/* ===== OUTPUT DISPLAY ===== */
.output-group { margin-bottom: 16px; }

.output-label {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.output-value {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -.02em;
}

.output-value.green { color: var(--green); }
.output-value.red { color: var(--red); }
.output-value.neutral { color: var(--text); }

.warning-badge {
  display: inline-block;
  background: rgba(255,77,79,.15);
  color: var(--red);
  font-size: .75rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  margin-top: 6px;
}

/* ===== HOMEPAGE GRID ===== */
.calc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.calc-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  text-decoration: none;
  color: var(--text);
  transition: background .15s, transform .15s;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.calc-card:hover {
  background: var(--card-alt);
  transform: translateY(-2px);
}

.calc-card h3 {
  font-size: 1rem;
  font-weight: 600;
}

.calc-card p {
  font-size: .85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.calc-card .arrow {
  color: var(--green);
  font-size: .85rem;
  font-weight: 600;
  margin-top: auto;
}

.section-label {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 12px;
  margin-top: 32px;
}

/* ===== EXAMPLE ===== */
.example-block {
  background: var(--bg);
  border-radius: 8px;
  padding: 20px;
  font-size: .9rem;
  line-height: 1.8;
}

.example-block code {
  color: var(--green);
  font-weight: 600;
  font-family: inherit;
}

/* ===== EXPLANATION / FAQ ===== */
.content-section { margin-top: 40px; }

.content-section h2 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 10px;
  letter-spacing: -.02em;
}

.content-section p,
.content-section li {
  color: var(--text-secondary);
  font-size: .95rem;
  line-height: 1.7;
  margin-bottom: 12px;
}

.content-section ul {
  padding-left: 20px;
  margin-bottom: 12px;
}

.faq-item { margin-bottom: 20px; }

.faq-item h3 {
  font-size: .95rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.faq-item p {
  color: var(--text-secondary);
  font-size: .9rem;
}

/* ===== CHART ===== */
.chart-wrap {
  position: relative;
  width: 100%;
  height: 300px;
  margin-top: 8px;
}

.chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ===== COLLAPSIBLE SL CALCULATOR ===== */
.sl-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: .85rem;
  font-weight: 500;
  padding: 8px 14px;
  cursor: pointer;
  transition: border-color .15s, color .15s;
  font-family: inherit;
  margin-bottom: 16px;
}

.sl-toggle-btn:hover {
  border-color: var(--green);
  color: var(--text);
}

.sl-toggle-btn .chevron {
  display: inline-block;
  transition: transform .2s;
  font-size: .7rem;
}

.sl-toggle-btn.open .chevron {
  transform: rotate(180deg);
}

.sl-panel {
  display: none;
  background: var(--bg);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
}

.sl-panel.open { display: block; }

.sl-panel-inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

/* ===== SL CALC LONG INDICATOR VISUAL ===== */
.sl-calc-visual {
  display: flex;
  align-items: stretch;
  padding: 8px 0;
}

.sl-calc-indicator {
  position: relative;
  width: 100%;
  height: 220px;
}

.sl-calc-level {
  position: absolute;
  left: 0;
  right: 50%;
  height: 0;
  transition: top .2s;
}

.sl-calc-level-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 0;
}

.sl-calc-level-tp .sl-calc-level-line {
  border-top: 1.5px solid var(--green);
}

.sl-calc-level-entry .sl-calc-level-line {
  border-top: 2px solid var(--text-secondary);
}

.sl-calc-level-sl .sl-calc-level-line {
  border-top: 2px solid var(--red);
}

.sl-calc-level-label {
  position: absolute;
  left: 0;
  font-size: .75rem;
  font-weight: 600;
  white-space: nowrap;
}

.sl-calc-level-tp .sl-calc-level-label {
  color: var(--green);
  bottom: 5px;
}

.sl-calc-level-entry .sl-calc-level-label {
  color: var(--text-secondary);
  bottom: 5px;
}

.sl-calc-level-sl .sl-calc-level-label {
  color: var(--red);
  top: 5px;
}

/* TP zone — green */
.sl-calc-tp-zone {
  position: absolute;
  left: 0;
  right: 50%;
  background: rgba(0,200,150,.08);
  transition: top .2s, height .2s;
}

/* Risk zone — red */
.sl-calc-risk-zone {
  position: absolute;
  left: 0;
  right: 50%;
  background: rgba(255,77,79,.12);
  transition: top .2s, height .2s;
}

/* Bracket — white */
.sl-calc-bracket {
  position: absolute;
  right: 42%;
  width: 12px;
  transition: top .2s, height .2s;
}

.sl-calc-bracket-stem {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  width: 0;
  border-right: 1.5px solid var(--text);
}

.sl-calc-bracket-top,
.sl-calc-bracket-bot {
  position: absolute;
  right: 0;
  width: 12px;
  height: 0;
  border-top: 1.5px solid var(--text);
}

.sl-calc-bracket-top { top: 0; }
.sl-calc-bracket-bot { bottom: 0; }

.sl-calc-bracket-label {
  position: absolute;
  top: 50%;
  left: calc(100% + 8px);
  transform: translateY(-50%);
  font-size: .75rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  white-space: nowrap;
}

/* ===== LOT SIZE ===== */
.lot-section {
  border-top: 1px solid var(--border);
  padding-top: 20px;
  margin-top: 4px;
}

.info-tooltip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-secondary);
  font-size: .65rem;
  font-weight: 700;
  cursor: help;
  margin-left: 4px;
  vertical-align: middle;
  flex-shrink: 0;
}

/* Tooltip — default (opens above) */
.info-tooltip .tooltip-text {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--card-alt);
  color: var(--text-secondary);
  font-size: .78rem;
  font-weight: 400;
  line-height: 1.5;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  width: 280px;
  text-transform: none;
  letter-spacing: 0;
  z-index: 50;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}

.info-tooltip .tooltip-text::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--card-alt);
}

.info-tooltip:hover .tooltip-text { display: block; }

/* Tooltip — opens below */
.info-tooltip--down .tooltip-text {
  bottom: auto;
  top: calc(100% + 8px);
}

.info-tooltip--down .tooltip-text::after {
  top: auto;
  bottom: 100%;
  left: 28px;
  transform: none;
  border-top-color: transparent;
  border-bottom-color: var(--card-alt);
}

/* Tooltip with visual — wider, side-by-side layout */
.info-tooltip .tooltip-text--visual {
  width: 500px;
  padding: 16px 24px 16px 16px;
  left: -20px;
  transform: translateX(0);
  overflow: visible;
}

.tt-layout {
  display: flex;
  gap: 16px;
  align-items: stretch;
}

.tt-text-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.tt-desc {
  display: block;
  margin-bottom: 12px;
}

.tt-example {
  display: block;
  color: var(--text-muted);
  font-size: .75rem;
  line-height: 1.5;
}

/* Visual column — right side */
.tt-visual-col {
  flex-shrink: 0;
  width: 170px;
  display: flex;
  align-items: stretch;
  padding-right: 10px;
}

/* Position indicator */
.tt-pos-indicator {
  display: block;
  position: relative;
  width: 100%;
  min-height: 160px;
  flex: 1;
}

/*
  Layout: TP at 5%, Entry at 75%, SL at 95%
  Profit zone: 5%–75% (70% height = 3x the SL zone)
  Risk zone: 75%–95% (~20% height)
*/

/* Horizontal levels */
.tt-level {
  position: absolute;
  left: 0;
  right: 50%;
  height: 0;
}

.tt-level-tp { top: 5%; }
.tt-level-entry { top: 75%; }
.tt-level-sl { top: 95%; }

.tt-level-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 0;
}

.tt-level-tp .tt-level-line {
  border-top: 1.5px solid var(--green);
}

.tt-level-entry .tt-level-line {
  border-top: 2px solid var(--text-secondary);
}

.tt-level-sl .tt-level-line {
  border-top: 2px solid var(--red);
}

.tt-level-label {
  position: absolute;
  left: 0;
  font-size: .6rem;
  font-weight: 600;
  white-space: nowrap;
}

.tt-level-tp .tt-level-label {
  color: var(--green);
  bottom: 4px;
}

.tt-level-entry .tt-level-label {
  color: var(--text-secondary);
  bottom: 4px;
}

.tt-level-sl .tt-level-label {
  color: var(--red);
  top: 4px;
}

/* Profit zone — green shaded area above entry */
.tt-tp-zone {
  position: absolute;
  top: 5%;
  height: 70%;
  left: 0;
  right: 50%;
  background: rgba(0,200,150,.08);
}

/* Risk zone — red shaded area below entry */
.tt-risk-zone {
  position: absolute;
  top: 75%;
  height: 20%;
  left: 0;
  right: 50%;
  background: rgba(255,77,79,.12);
}

/* Bracket — white, on the right side of risk zone */
.tt-pos-bracket {
  position: absolute;
  top: 75%;
  height: 20%;
  right: 42%;
  width: 10px;
}

.tt-pos-bracket-stem {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  width: 0;
  border-right: 1.5px solid var(--text);
}

.tt-pos-bracket-top,
.tt-pos-bracket-bot {
  position: absolute;
  right: 0;
  width: 10px;
  height: 0;
  border-top: 1.5px solid var(--text);
}

.tt-pos-bracket-top { top: 0; }
.tt-pos-bracket-bot { bottom: 0; }

.tt-pos-bracket-label {
  position: absolute;
  top: 50%;
  right: -4px;
  transform: translateY(-50%) translateX(100%);
  font-size: .58rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .sl-panel-inner { grid-template-columns: 1fr; }
  .price-visual { margin-top: 16px; }
  .info-tooltip .tooltip-text {
    left: auto;
    right: -10px;
    transform: none;
  }
  .info-tooltip .tooltip-text::after {
    left: auto;
    right: 14px;
    transform: none;
  }
  .info-tooltip--down .tooltip-text {
    left: -10px;
    right: auto;
    transform: none;
  }
  .info-tooltip--down .tooltip-text::after {
    left: 14px;
    right: auto;
    transform: none;
  }
}

/* ===== FOOTER ===== */
footer {
  text-align: center;
  padding: 40px 20px;
  font-size: .8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
  .calc-section { grid-template-columns: 1fr; }
  .calc-grid { grid-template-columns: 1fr; }

  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 16px 20px;
    gap: 16px;
  }

  .nav-links.open { display: flex; }
  .nav-toggle { display: block; }

  .hero { padding: 40px 20px 24px; }
  .container { padding: 24px 16px 60px; }
}
