/* Laptop layout mockup. Applies only at >= 1000px, so phones and tablets keep
   the current single column exactly as it is. */

.hero { margin: 0 0 22px; }
.hero h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; margin-bottom: 6px; }
.hero p { font-size: 14px; color: var(--ink-secondary); line-height: 1.55; max-width: 64ch; }

.results-empty { display: none; }
.divider { display: none; }

@media (min-width: 1000px) {
  .wrap { max-width: min(1680px, calc(100vw - 64px)); }

  .hero h1 { font-size: 32px; }
  .hero p { font-size: 15px; }

  /* --left-w is set inline by the drag handle; these are the defaults. */
  .layout {
    --left-w: 410px;
    display: grid;
    grid-template-columns: var(--left-w) 24px minmax(0, 1fr);
    align-items: start;
  }

  /* Scrolls with the page, so there is one scrollbar, not two. */
  .controls { min-width: 0; }
  .controls .step {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 16px;
  }
  .controls .picker-row { grid-template-columns: 1fr; }
  .controls .runbar { bottom: 12px; }

  .output { min-width: 0; container-type: inline-size; container-name: output; }
  .output .step {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
  }

  /* Drag handle between the two columns. */
  .divider {
    display: block;
    align-self: stretch;
    position: relative;
    cursor: col-resize;
    touch-action: none;
    outline: none;
  }
  .divider::before {
    content: "";
    position: absolute;
    top: 0; bottom: 0; left: 50%;
    width: 2px; margin-left: -1px;
    background: var(--border);
    border-radius: 2px;
    transition: background 0.12s ease, width 0.12s ease, margin-left 0.12s ease;
  }
  .divider::after {
    content: "";
    position: absolute;
    top: 120px; left: 50%;
    width: 6px; height: 40px; margin-left: -3px;
    border-radius: 3px;
    background: var(--border-strong);
  }
  .divider:hover::before, .divider:focus-visible::before, .divider.dragging::before {
    background: var(--brand); width: 4px; margin-left: -2px;
  }
  .divider:hover::after, .divider:focus-visible::after, .divider.dragging::after { background: var(--brand); }
  body.resizing { cursor: col-resize; user-select: none; }

  #resultsWrap[hidden] + .results-empty { display: block; }
  .results-empty .re-msg {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 240px;
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    background: var(--surface-alt);
    color: var(--ink-muted);
    padding: 32px;
  }
  .results-empty .big { font-size: 36px; font-weight: 800; letter-spacing: -0.025em; line-height: 1.15; color: var(--ink-secondary); margin-bottom: 12px; }
  .results-empty .small { font-size: 20px; max-width: 34ch; line-height: 1.5; }
  .results-empty .re-side { margin-top: 16px; }

  /* The strategy panel. On a laptop the results column is too narrow to put it
     beside the table, so by default it is a full-width card above the table with
     its text in two columns; the wide layout below moves it to the right. */
  #results > .strategy-info,
  .results-empty .re-side > .strategy-info {
    display: block;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    padding: 16px 18px;
    margin-bottom: 12px;
    font-size: 13px;
    line-height: 1.55;
    color: var(--ink-secondary);
  }
  .strategy-info .si-body > * { break-inside: avoid; }
  .strategy-info .si-toggle { display: none; }
  .pattern-table tbody tr.pick { cursor: pointer; }
  .pattern-table tbody tr.pick:hover td { background: var(--surface-alt); }
  .pattern-table tbody tr.sel td { background: var(--brand-light); }

  .strategy-info .si-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 8px; }
  .strategy-info h3 { font-size: 17px; font-weight: 800; letter-spacing: -0.01em; color: var(--ink); }
  .strategy-info .si-tag {
    display: inline-block; font-family: var(--font-mono); font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.05em; color: var(--brand);
    background: var(--brand-light); border-radius: var(--radius-pill); padding: 2px 9px;
  }
  .strategy-info .si-what { margin-bottom: 12px; }
  .strategy-info .si-result {
    background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 8px 10px; margin-bottom: 12px; color: var(--ink); font-size: 12.5px;
  }
  .strategy-info .si-k {
    display: block; font-family: var(--font-mono); font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-muted); margin-bottom: 2px;
  }
  .strategy-info .si-rules > div,
  .strategy-info .si-block,
  .strategy-info .si-source { margin-bottom: 10px; }
  .strategy-info .si-fine { font-size: 11.5px; color: var(--ink-muted); }
  .strategy-info .si-source a { color: var(--brand); font-weight: 700; text-decoration: none; }
  .strategy-info .si-source a:hover { text-decoration: underline; }
  .strategy-info .si-empty { column-span: all; text-align: center; padding: 18px 6px; color: var(--ink-muted); }
  .strategy-info .si-empty-big { font-size: 17px; font-weight: 800; color: var(--ink-secondary); margin-bottom: 6px; }
}

@media (min-width: 1500px) {
  .layout { --left-w: 450px; }
}

/* Results: when the results column is wide enough, the table stays compact on
   the left and the period summary and the buy-and-hold verdict sit beside it.
   The trade log and the footnote keep the full width underneath. A container
   query is used because the available width depends on the draggable divider,
   not on the window. */
@container output (min-width: 1100px) {
  #results {
    display: grid;
    grid-template-columns: minmax(0, 760px) minmax(240px, 1fr);
    grid-template-rows: max-content max-content max-content 1fr;
    column-gap: 24px;
    align-items: start;
  }
  #results > .pattern-scroll { grid-column: 1; grid-row: 1 / 5; }
  #results > .period-strip   { grid-column: 2; grid-row: 1; margin-bottom: 12px; }
  #results > .info-box,
  #results > .warn-box       { grid-column: 2; margin-bottom: 12px; }
  #results > .tl-panel,
  #results > .settings-note  { grid-column: 1 / -1; }

  /* Before a run: message on the left, the strategy panel on the right. */
  #resultsWrap[hidden] + .results-empty {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 400px);
    gap: 24px;
    align-items: start;
  }
  /* Wide: the panel moves to the right-hand column, always open. */
  #results > .strategy-info { grid-column: 2; margin-bottom: 0; }
  .results-empty .re-side { margin-top: 0; }
  .results-empty .re-side > .strategy-info { margin-bottom: 0; }
  .results-empty .re-msg { min-height: 420px; }
}

/* Narrow results column (a laptop at 100% zoom): the panel sits above the table,
   its detail runs in two columns, and a button folds it down to the heading and
   summary so the table stays on the first screen. */
@container output (max-width: 1099px) {
  .strategy-info .si-body { column-count: 2; column-gap: 28px; }
  .strategy-info.collapsed .si-body { display: none; }
  .strategy-info .si-toggle {
    display: inline-block;
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    color: var(--brand);
    background: none;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-pill);
    padding: 4px 11px;
    cursor: pointer;
  }
  .strategy-info .si-toggle:hover { background: var(--brand-light); }
}

/* Outside the wide results layout the panel is not shown. */
.strategy-info { display: none; }

/* Results table, all widths: the strategy name may wrap and its small tag
   ("15-min, intraday", "edited") sits on its own line underneath instead of
   widening the first column. */
#results .pattern-table td:first-child { white-space: normal; }
#results .pattern-table td:first-child .thin-flag {
  display: block;
  width: fit-content;
  margin-top: 3px;
}

/* On a phone the first three columns (name, details, return) are what matter,
   so they are kept compact enough to show together without scrolling sideways;
   trades, win %, vs hold and drawdown follow to the right. */
@media (max-width: 700px) {
  #results .pattern-table th,
  #results .pattern-table td { padding: 9px 8px; }
  #results .pattern-table th:first-child,
  #results .pattern-table td:first-child { min-width: 104px; max-width: 150px; }
}

/* A strategy that cannot run on this stock (no intraday data, or a failure)
   shows one long message across the row. Left on one line it stretched the
   whole table far past its box and crushed the strategy names; let it wrap. */
#results .pattern-table td[colspan] {
  white-space: normal;
  font-size: 12px;
  line-height: 1.45;
}

/* With that message wrapped inside the narrower columns, keep the name column
   from being squeezed. (On a phone the rule above, max-width 700px, governs.) */
@media (min-width: 701px) {
  #results .pattern-table th:first-child,
  #results .pattern-table td:first-child { min-width: 200px; }
}
