/* Position size calculator page. Loaded after landing.css (tokens, header,
   footer, buttons, FAQ) and breadcrumb.css; driven by
   position-size-calculator.js. */

.calc-page {
  background: var(--bg);
}

.calc-hero {
  padding: 72px 0 40px;
  background: #ffffff;
}

.calc-hero h1 {
  margin: 0 0 16px;
  color: var(--text);
  font-size: clamp(36px, 4.6vw, 56px);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: 0;
}

.calc-lead {
  max-width: 720px;
  margin: 0;
  color: #42464d;
  font-size: 18px;
  line-height: 1.6;
}

/* ---- The calculator ------------------------------------------------------- */
.calc-section {
  padding: 8px 0 72px;
  background: linear-gradient(180deg, #ffffff 0%, var(--bg) 100%);
}

.calc-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 20px;
  align-items: start;
}

.calc-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.calc-form {
  display: grid;
  gap: 16px;
  padding: 24px;
}

.calc-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.calc-row-account,
.calc-row-prices {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.calc-row-account {
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 0.8fr) minmax(0, 0.8fr);
}

/* A row whose every field is hidden (no rate, no Custom) takes no room. */
.calc-row:not(:has(> label:not([hidden]))) {
  display: none;
}

.calc-form label {
  display: grid;
  gap: 7px;
  align-content: end;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.calc-form label[hidden] {
  display: none;
}

.calc-form label > span {
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.calc-form label small {
  color: var(--faint);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: none;
}

.calc-form input,
.calc-form select {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #ffffff;
  color: var(--text);
  font-family: var(--font-main);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  text-transform: none;
}

.calc-form select {
  appearance: none;
  padding-right: 34px;
  background-image:
    linear-gradient(45deg, transparent 50%, #6e6e73 50%),
    linear-gradient(135deg, #6e6e73 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 13px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

.calc-form input:focus-visible,
.calc-form select:focus-visible {
  border-color: var(--accent);
  outline: 3px solid rgba(0, 113, 227, 0.16);
  outline-offset: 0;
}

.calc-form-note {
  margin: 2px 0 0;
  color: var(--faint);
  font-size: 13px;
  line-height: 1.55;
}

.calc-results {
  position: sticky;
  top: 96px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 16px;
}

.calc-tile {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.calc-tile small {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.calc-tile b {
  display: block;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.calc-tile span {
  display: block;
  margin-top: 6px;
  color: var(--faint);
  font-size: 12px;
  line-height: 1.4;
}

.calc-tile-main {
  grid-column: 1 / -1;
  border-color: rgba(0, 113, 227, 0.22);
  background: rgba(0, 113, 227, 0.05);
}

.calc-tile-main b {
  color: var(--accent-deep);
  font-size: 30px;
}

.calc-neg {
  color: var(--danger) !important;
}

.calc-pos {
  color: var(--teal-deep) !important;
}

.calc-notes {
  grid-column: 1 / -1;
  margin: 4px 2px 0;
  color: #42464d;
  font-size: 13px;
  line-height: 1.55;
}

.calc-tile span[hidden],
.calc-notes[hidden] {
  display: none;
}

/* ---- Journal band --------------------------------------------------------- */
.calc-cta-section {
  padding: 0 0 72px;
}

.calc-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 24px 40px;
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #ffffff;
}

.calc-cta > div:first-child {
  max-width: 640px;
}

.calc-kicker {
  display: block;
  margin-bottom: 10px;
  color: var(--accent-deep);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.calc-cta h2 {
  margin: 0 0 10px;
  font-size: clamp(24px, 3vw, 32px);
  line-height: 1.15;
  letter-spacing: 0;
}

.calc-cta p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

.calc-cta-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

/* ---- Explainer ------------------------------------------------------------ */
.calc-guide {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 56px;
  padding-top: 24px;
  padding-bottom: 24px;
}

.calc-guide h2 {
  margin: 0 0 14px;
  font-size: 26px;
  line-height: 1.2;
  letter-spacing: 0;
}

.calc-guide p {
  margin: 0 0 14px;
  color: #42464d;
  font-size: 15px;
  line-height: 1.7;
}

.calc-formula {
  padding: 14px 16px;
  border-left: 3px solid var(--accent);
  border-radius: 0 10px 10px 0;
  background: #ffffff;
  color: var(--text) !important;
  font-family: var(--font-mono);
  font-size: 13px !important;
}

.calc-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
}

.calc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.calc-table th,
.calc-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.calc-table th {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.calc-table tr:last-child td {
  border-bottom: 0;
}

.calc-table td:first-child {
  color: var(--text);
  font-weight: 600;
}

/* ---- Narrower screens ----------------------------------------------------- */
@media (max-width: 980px) {
  .calc-grid,
  .calc-guide {
    grid-template-columns: minmax(0, 1fr);
  }

  .calc-results {
    position: static;
  }
}

@media (max-width: 620px) {
  .calc-hero {
    padding: 48px 0 28px;
  }

  .calc-lead {
    font-size: 16px;
  }

  .calc-form {
    padding: 18px;
  }

  .calc-row,
  .calc-row-account,
  .calc-row-prices {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* Instrument names are long ("NQ — E-mini Nasdaq-100"): one per row. */
  .calc-row-instrument {
    grid-template-columns: minmax(0, 1fr);
  }

  /* Balance takes the full row; currency and risk % share the next. */
  .calc-row-account > label:first-child {
    grid-column: 1 / -1;
  }

  .calc-results {
    padding: 12px;
  }

  .calc-tile {
    padding: 12px;
  }

  .calc-tile b {
    font-size: 16px;
  }

  .calc-tile-main b {
    font-size: 24px;
  }

  .calc-cta {
    padding: 22px;
  }

  .calc-cta-actions,
  .calc-cta-actions .button {
    width: 100%;
  }

}

/* ---- Phones: result bar, table as cards, breadcrumb targets --------------- */
.calc-sticky {
  display: none;
}

/* The result bar links here; land below the fixed header, not under it. */
#calcResults {
  scroll-margin-top: 88px;
}

@media (max-width: 980px) {
  .calc-sticky:not([hidden]) {
    position: fixed;
    right: 16px;
    bottom: max(16px, env(safe-area-inset-bottom));
    left: 16px;
    z-index: 60;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 52px;
    padding: 10px 16px;
    border: 1px solid rgba(0, 113, 227, 0.22);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.14);
    color: var(--text);
    text-decoration: none;
    backdrop-filter: blur(10px);
  }

  .calc-sticky span:first-child {
    color: var(--accent-deep);
    font-family: var(--font-mono);
    font-size: 16px;
    font-weight: 600;
  }

  .calc-sticky span:nth-child(2) {
    flex: 1;
    color: var(--danger);
    font-family: var(--font-mono);
    font-size: 13px;
  }

  .calc-sticky span:last-child {
    color: var(--muted);
  }
}

@media (max-width: 620px) {
  /* A 24px-tall target at least, without moving the trail. */
  .calc-page .breadcrumb a {
    display: inline-block;
    padding: 4px 0;
    margin: -4px 0;
  }

  /* Four columns do not fit a phone; each row becomes a card, every value
     under its own label, instead of a table to swipe sideways. */
  .calc-table-wrap {
    overflow: visible;
  }

  .calc-table {
    min-width: 0;
  }

  .calc-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .calc-table tbody,
  .calc-table tr,
  .calc-table td {
    display: block;
  }

  .calc-table tr {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
  }

  .calc-table tr:last-child {
    border-bottom: 0;
  }

  .calc-table td {
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr);
    gap: 10px;
    padding: 3px 0;
    border: 0;
  }

  .calc-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .calc-table td:first-child {
    display: block;
    margin-bottom: 4px;
    font-size: 15px;
  }

  .calc-table td:first-child::before {
    content: none;
  }
}
