/* Planner-specific polish (builds on styles.css) */

/* Align two-column labels so input boxes line up */
@media (min-width: 721px){
  .planner-shell .form-grid .field > label{ min-height: 2.4em; }
}

.planner-shell{
  padding: 18px;
}

.planner-hero{
  display: grid;
  gap: 16px;
  grid-template-columns: 1.15fr 0.85fr;
  align-items: start;
}
@media (max-width: 900px){
  .planner-hero{ grid-template-columns: 1fr; }
}

.planner-hero h1{
  margin: 0 0 8px 0;
  font-size: clamp(26px, 4vw, 40px);
  letter-spacing: -0.03em;
  line-height: 1.08;
}
.planner-hero p{
  margin: 0;
  color: var(--muted);
  max-width: 70ch;
}

.planner-hero-card{
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-2) 72%, transparent);
  padding: 14px 14px;
}

.hero-list{
  margin: 10px 0 0 0;
  padding-left: 18px;
  color: var(--muted);
}
.hero-list li{ margin: 8px 0; }

kbd{
  font-family: var(--mono);
  font-size: 0.9em;
  padding: 2px 6px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.planner-layout{
  margin-top: 14px;
}

.step{
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 14px;
}
.step + .step{ margin-top: 12px; }

.step-head{
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 10px;
}
.step-num{
  width: 34px;
  height: 34px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: white;
  font-weight: 900;
  background: linear-gradient(135deg, var(--primary), #22c55e);
  flex: 0 0 auto;
}
.step h2{
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}
.step p{ margin: 4px 0 0 0; }

.details{
  margin-top: 10px;
}
.details summary{
  cursor: pointer;
  font-weight: 750;
  color: var(--text);
}
.details[open] summary{ margin-bottom: 10px; }
.details .small{ margin-top: 8px; }

.seg{
  display: inline-flex;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  padding: 4px;
  gap: 4px;
  width: fit-content;
}
.seg button{
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text);
  font-weight: 800;
  padding: 10px 12px;
  border-radius: 999px;
  cursor: pointer;
  min-height: 40px;
}
.seg button:hover{ background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.seg button[aria-pressed="true"]{
  /* Fallback for browsers without color-mix() */
  background: var(--primary);
  color: white;

  /* Enhanced gradient when supported */
  background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 92%, white), var(--primary));
}

.qc{
  display: grid;
  gap: 10px;
}
.qc-row{
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-2) 72%, transparent);
}
.qc-title{
  font-weight: 850;
  letter-spacing: -0.02em;
}
.qc-value{
  font-weight: 900;
  font-family: var(--mono);
}

.stackBlock{
  margin-top: 10px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-2) 72%, transparent);
  padding: 12px;
}
.stackTop{
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 8px;
}
.stackLabel{
  font-weight: 850;
  letter-spacing: -0.02em;
}
.stackNumbers{
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.95rem;
}
.stackBar{
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  /* Fallback track color */
  background: rgba(0,0,0,0.08);
  background: color-mix(in srgb, var(--text) 10%, transparent);
  display: flex;
}

/* Better fallback track in dark mode if color-mix() is unsupported */
@media (prefers-color-scheme: dark){
  .stackBar{ background: rgba(255,255,255,0.12); }
}
html[data-theme="dark"] .stackBar{ background: rgba(255,255,255,0.12); }
html[data-theme="light"] .stackBar{ background: rgba(0,0,0,0.08); }

.stackBar .barseg{
  height: 100%;
  width: 0%;
  transition: width 160ms ease;
}
.stackBar .barseg.used{
  background: rgba(148,163,184,0.55);
}
@media (prefers-color-scheme: dark){
  .stackBar .barseg.used{ background: rgba(148,163,184,0.28); }
}
html[data-theme="dark"] .stackBar .barseg.used{ background: rgba(148,163,184,0.28); }

.stackBar .barseg.planned{
  background: linear-gradient(90deg, var(--primary), #22c55e);
}

.muted{ color: var(--muted); }

/* ---------------------------------------------------------------
   Missing layout classes used in planner.html
   (keeps the planner aligned + readable on mobile and desktop)
   --------------------------------------------------------------- */

.planner-badges{
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.planner-panel,
.planner-results{
  padding: 18px;
}
@media (max-width: 720px){
  .planner-panel,
  .planner-results{
    padding: 14px;
  }
}

/* Results notice spacing (keeps consistent gap to the totals card) */
.planner-results #plannerNotice.notice{
  margin-top: 10px;
  margin-bottom: 12px;
}

.input-panels{
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (max-width: 780px){
  .input-panels{ grid-template-columns: 1fr; }
}

.subcard{
  border-radius: 14px;
  border: 1px solid var(--border);
  /* Fallback */
  background: var(--surface-2);
  background: color-mix(in srgb, var(--surface-2) 72%, transparent);
  padding: 12px;
}
.subcard h3{
  margin: 0 0 10px 0;
  font-size: 1rem;
  letter-spacing: -0.02em;
}
.subcard-title{
  font-weight: 850;
  letter-spacing: -0.02em;
}

.kpi-big{
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  background: color-mix(in srgb, var(--surface-2) 68%, transparent);
  padding: 14px;
}
.value-xl{
  font-weight: 950;
  letter-spacing: -0.03em;
  font-size: clamp(1.85rem, 3.8vw, 2.35rem);
  line-height: 1.05;
}

.kpi{
  display: grid;
  gap: 4px;
}
.kpi .value{
  font-weight: 950;
  letter-spacing: -0.02em;
  font-size: 1.35rem;
  line-height: 1.1;
}
.kpi .label{
  color: var(--muted);
  font-weight: 650;
  font-size: 0.92rem;
}

.kpi-row{
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (max-width: 780px){
  .kpi-row{ grid-template-columns: 1fr; }
}

.pill-mini{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-family: var(--mono);
  font-weight: 900;
  font-size: 0.9rem;
}

.qc-grid{
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(90px, 1fr) minmax(90px, 1fr);
  gap: 10px;
  align-items: center;
}
.qc-head{
  color: var(--muted);
  font-weight: 850;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.qc-rowlabel{
  font-weight: 850;
  letter-spacing: -0.02em;
}
.qc-grid .qc-value{
  text-align: right;
}
@media (max-width: 520px){
  .qc-grid{
    grid-template-columns: minmax(100px, 1fr) minmax(80px, 1fr) minmax(80px, 1fr);
    gap: 8px;
  }
}


/* ------------------------------------------------------------------
   Fixes: alignment + pool usage over-states
   ------------------------------------------------------------------ */

/* Ensure the two result cards stretch to the same height in the grid */
.kpi-row{
  align-items: stretch;
}

/* Make result cards flex so the "time" KPI can align at the bottom */
#p1ResultCard,
#p2ResultCard{
  display: flex;
  flex-direction: column;
}

#p1ResultCard .kpi:last-of-type,
#p2ResultCard .kpi:last-of-type{
  margin-top: auto;
}

/* Highlight pools that exceed their available days */
.stackBlock.over{
  border-color: rgba(220,38,38,0.55);
}
@supports (color: color-mix(in srgb, white 50%, black)){
  .stackBlock.over{
    border-color: color-mix(in srgb, var(--danger) 45%, var(--border));
  }
}

.stackNumbers.over{
  color: var(--danger);
  font-weight: 900;
}


/* ------------------------------------------------------------------
   Visibility accents: stronger borders for planner boxes (theme-safe)
   ------------------------------------------------------------------ */

/* Fallback accent for browsers without color-mix() */
.planner-shell .step,
.planner-shell .subcard,
.planner-shell .planner-hero-card,
.planner-shell .qc-row,
.planner-shell .stackBlock,
.planner-shell .kpi-big{
  border-color: rgba(15, 118, 110, 0.28);
}

/* Enhanced accent using theme tokens when supported */
@supports (color: color-mix(in srgb, white 50%, black)){
  .planner-shell .step,
  .planner-shell .subcard,
  .planner-shell .planner-hero-card,
  .planner-shell .qc-row,
  .planner-shell .stackBlock,
  .planner-shell .kpi-big{
    border-color: color-mix(in srgb, var(--primary) 22%, var(--border));
  }
}

/* Preset buttons: solid, more visible outline */
#twoParentControls .btn{
  border-style: solid;
  border-color: rgba(15, 118, 110, 0.42);
  background: rgba(15, 118, 110, 0.06);
}

/* ------------------------------------------------------------------
   Layout: stack Results below "Your plan" (also on desktop)
   ------------------------------------------------------------------ */

@media (min-width: 980px){
  .planner-page .planner-layout{
    grid-template-columns: 1fr;
  }
  .planner-page .planner-layout .sticky{
    position: static;
    top: auto;
  }
}

/* ------------------------------------------------------------------
   Schedule compare: show Parent 1 next to Parent 2 on wide screens
   ------------------------------------------------------------------ */

.planner-page #scenarioTables{
  display: grid;
  gap: 12px;
  margin-top: 10px;
}

.planner-page #scenarioTables > div{
  /* Remove the inline margin-top used by the renderer */
  margin-top: 0 !important;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface-2) 72%, transparent);
  padding: 12px;
}

/* Avoid double borders: the scenario card provides the frame */
.planner-page #scenarioTables > div .table-wrap{
  border: 0;
  background: transparent;
  margin-top: 8px;
}

@media (min-width: 920px){
  .planner-page #scenarioTables{
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }
}
@supports (color: color-mix(in srgb, white 50%, black)){
  #twoParentControls .btn{
    border-color: color-mix(in srgb, var(--primary) 42%, var(--border));
    background: color-mix(in srgb, var(--primary) 10%, var(--surface));
  }
  #twoParentControls .btn:hover{
    background: color-mix(in srgb, var(--primary) 14%, var(--surface));
  }
}

/* ------------------------------------------------------------------
   Schedule compare table (1–7 days/week)
   ------------------------------------------------------------------ */

.table-wrap{
  margin-top: 8px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-2) 72%, transparent);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-wrap .table{ margin: 0; }
.scenario-table th,
.scenario-table td{ white-space: nowrap; }

.scenario-table tbody tr.row-highlight td{
  background: rgba(15, 118, 110, 0.06);
}
@supports (color: color-mix(in srgb, white 50%, black)){
  .scenario-table tbody tr.row-highlight td{
    background: color-mix(in srgb, var(--primary) 10%, var(--surface));
  }
}

.scenario-table tbody tr.row-selected td{
  font-weight: 900;
  background: rgba(15, 118, 110, 0.10);
}
@supports (color: color-mix(in srgb, white 50%, black)){
  .scenario-table tbody tr.row-selected td{
    background: color-mix(in srgb, var(--primary) 16%, var(--surface));
  }
}

.scenario-table tbody tr.row-selected td:first-child{
  border-left: 4px solid var(--primary);
}
