/* Little Words — /tools/ suite shared styles.
   Sits on top of /core/tokens.css; adds nothing a game or the flashcard player
   already owns. Three jobs it does that the rest of the site does not:

   1. laptop layout. Every other surface here is a phone-first toy. These are
      working tools an SLP drives from a laptop mid-session, so the grid opens
      up past 900px instead of staying in a 640px column.
   2. print. US Letter, 0.5in margins, chrome dropped, ink-friendly (white
      ground, hairline rules, no filled panels). A printed board is the artifact
      that goes home in a backpack, so it has to look deliberate, not like a
      screenshot of a web page.
   3. a shared control vocabulary (toolbar, picker, chips, cells) so the five
      tools feel like one suite. */

:root {
  --t-line: #E6DED2;
  --t-line-soft: #F0E9DE;
  --t-muted: #6B7280;
  --t-max: 1120px;
}

body.lw-tools {
  background: var(--lw-bg, #FFFBF5);
  color: var(--lw-ink, #1E2A4A);
  font-family: var(--lw-font-body, system-ui, sans-serif);
  margin: 0;
}

.t-wrap { max-width: var(--t-max); margin: 0 auto; padding: 0 16px 64px; }
.t-wrap--narrow { max-width: 820px; }

/* ---------- page head ---------- */
.t-head { padding: 24px 0 8px; }
.t-head h1 {
  font-family: var(--lw-font-display, system-ui);
  font-size: clamp(1.6rem, 5vw, 2.3rem);
  line-height: 1.15; margin: 0 0 8px;
}
.t-head p { margin: 0; max-width: 62ch; color: var(--t-muted); font-size: 1rem; line-height: 1.55; }
.t-head .t-free {
  display: inline-flex; align-items: center; gap: 6px; margin-bottom: 10px;
  background: var(--lw-bg-warm, #FFF0E8); color: var(--lw-primary-deep, #BE4327);
  border-radius: 999px; padding: 5px 12px; font-size: .82rem; font-weight: 700;
}

/* ---------- panels ---------- */
.t-panel {
  background: var(--lw-surface, #fff); border: 1px solid var(--t-line);
  border-radius: var(--lw-radius, 16px); padding: 16px; margin: 16px 0;
}
.t-panel > h2 {
  font-family: var(--lw-font-display, system-ui);
  font-size: 1.05rem; margin: 0 0 4px;
}
.t-panel > h2 + p { margin: 0 0 12px; color: var(--t-muted); font-size: .9rem; }

.t-step { display: flex; align-items: baseline; gap: 8px; }
.t-step b {
  flex: none; width: 26px; height: 26px; border-radius: 999px;
  background: var(--lw-primary, #F28B6E); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .85rem; font-family: var(--lw-font-body, system-ui);
}

/* ---------- controls ---------- */
.t-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.t-row--end { justify-content: flex-end; }

.t-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 44px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--lw-primary-deep, #BE4327);
  background: var(--lw-primary, #F28B6E); color: #fff;
  font: inherit; font-weight: 700; cursor: pointer; text-decoration: none;
  transition: transform var(--lw-dur-quick, .12s) var(--lw-ease-out, ease);
}
.t-btn:hover { transform: translateY(-1px); }
.t-btn:active { transform: translateY(0); }
.t-btn--ghost { background: #fff; color: var(--lw-ink, #1E2A4A); border-color: var(--t-line); }
.t-btn--ghost:hover { background: var(--lw-bg-warm, #FFF0E8); }
.t-btn[disabled] { opacity: .45; cursor: default; transform: none; }
.t-btn--sm { min-height: 44px; padding: 0 12px; font-size: .88rem; }

.t-field { display: flex; flex-direction: column; gap: 5px; }
.t-field > span { font-size: .82rem; font-weight: 700; color: var(--t-muted); }
.t-input, .t-select {
  min-height: 44px; padding: 0 12px; border-radius: 12px;
  border: 1px solid var(--t-line); background: #fff; color: inherit;
  font: inherit; font-size: 1rem; max-width: 100%;
}
.t-input:focus, .t-select:focus, .t-btn:focus-visible, .t-chip:focus-visible {
  outline: 3px solid var(--lw-sky, #7CC3E0); outline-offset: 2px;
}
textarea.t-input { min-height: 88px; padding: 10px 12px; line-height: 1.5; resize: vertical; }

.t-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.t-chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--t-line); background: #fff; color: inherit;
  font: inherit; font-size: .9rem; font-weight: 650; cursor: pointer;
}
.t-chip:hover { background: var(--lw-bg-warm, #FFF0E8); }
.t-chip[aria-pressed="true"], .t-chip.is-on {
  background: var(--lw-primary, #F28B6E); border-color: var(--lw-primary-deep, #BE4327); color: #fff;
}

.t-note { font-size: .85rem; color: var(--t-muted); line-height: 1.5; margin: 8px 0 0; }
.t-note a { color: var(--lw-primary-deep, #BE4327); }

/* ---------- card picker ---------- */
.t-picker { display: grid; gap: 12px; }
@media (min-width: 900px) { .t-picker { grid-template-columns: 240px 1fr; align-items: start; } }

.t-decklist { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.t-decklist::-webkit-scrollbar { height: 6px; }
@media (min-width: 900px) {
  .t-decklist { flex-direction: column; overflow: visible; max-height: 460px; overflow-y: auto; }
}
.t-deckbtn {
  flex: none; display: flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 12px; border-radius: 12px;
  border: 1px solid var(--t-line); background: #fff; color: inherit;
  font: inherit; font-size: .88rem; font-weight: 650; cursor: pointer;
  white-space: nowrap; text-align: left;
}
@media (min-width: 900px) { .t-deckbtn { width: 100%; white-space: normal; } }
.t-deckbtn[aria-pressed="true"] { background: var(--lw-bg-warm, #FFF0E8); border-color: var(--lw-primary, #F28B6E); }

.t-cardgrid {
  display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  max-height: 460px; overflow-y: auto; padding: 2px;
}
.t-cardbtn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-height: 44px; padding: 6px 4px; border-radius: 12px;
  border: 1px solid var(--t-line); background: #fff; color: inherit;
  font: inherit; font-size: .78rem; font-weight: 650; cursor: pointer;
}
.t-cardbtn:hover { border-color: var(--lw-primary, #F28B6E); background: var(--lw-bg-warm, #FFF0E8); }
.t-cardbtn img { width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: 8px; }
.t-cardbtn .ph { width: 100%; aspect-ratio: 1; display: grid; place-items: center; font-size: 1.8rem; }
.t-cardbtn .w { display: block; max-width: 100%; overflow-wrap: anywhere; }

/* ---------- the board / strip ---------- */
.t-board { display: grid; gap: 10px; margin: 0; }
.t-board[data-cols="1"] { grid-template-columns: 1fr; }
.t-board[data-cols="2"] { grid-template-columns: repeat(2, 1fr); }
.t-board[data-cols="3"] { grid-template-columns: repeat(3, 1fr); }

.t-cell {
  position: relative; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 6px; padding: 10px 8px;
  min-height: 128px; border-radius: 16px;
  border: 2px solid var(--t-line); background: #fff;
  font: inherit; cursor: pointer; text-align: center; color: inherit;
  transition: transform var(--lw-dur-quick, .12s) var(--lw-ease-pop, ease);
}
@media (min-width: 700px) { .t-cell { min-height: 168px; } }
.t-cell:hover { border-color: var(--lw-primary, #F28B6E); }
.t-cell:active { transform: scale(.97); }
.t-cell.is-speaking { border-color: var(--lw-primary-deep, #BE4327); }
.t-cell img { width: 100%; max-height: 116px; object-fit: contain; }
.t-cell .ph { font-size: 2.6rem; line-height: 1; }
.t-cell .w {
  font-family: var(--lw-font-display, system-ui); font-weight: 800;
  font-size: clamp(1rem, 3.4vw, 1.35rem); overflow-wrap: anywhere;
}
.t-cell--empty { border-style: dashed; color: var(--t-muted); font-weight: 650; }
.t-cell .t-cellnum {
  position: absolute; top: 6px; left: 8px; font-size: .78rem;
  font-weight: 800; color: var(--t-muted);
}
.t-cellbar { display: flex; justify-content: center; gap: 4px; margin-top: 4px; }
.t-iconbtn {
  min-width: 44px; min-height: 44px; border-radius: 10px; border: 1px solid var(--t-line);
  background: #fff; color: inherit; font: inherit; font-size: 1rem; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.t-iconbtn:hover { background: var(--lw-bg-warm, #FFF0E8); }

/* ---------- schedule strip ---------- */
.t-strip { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 620px) { .t-strip { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); } }
.t-strip .t-cell { min-height: 150px; }
.t-firstthen { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .t-firstthen { grid-template-columns: 1fr 1fr; } }
.t-slotlabel {
  font-family: var(--lw-font-display, system-ui); font-weight: 800;
  font-size: .95rem; margin: 0 0 6px; color: var(--lw-primary-deep, #BE4327);
  text-transform: uppercase; letter-spacing: .04em;
}

/* ---------- tables (data sheet, plan) ---------- */
.t-tablewrap { overflow-x: auto; }
.t-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.t-table th, .t-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--t-line-soft); vertical-align: middle; }
.t-table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--t-muted); }
.t-table tbody tr:last-child td { border-bottom: 0; }
.t-num { font-variant-numeric: tabular-nums; }

/* ---------- share row ---------- */
.t-share { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.t-share .t-input { flex: 1 1 240px; font-size: .85rem; }

.t-status { min-height: 20px; font-size: .85rem; color: var(--lw-primary-deep, #BE4327); font-weight: 650; }

/* ---------- cross links ---------- */
.t-links { display: grid; gap: 10px; grid-template-columns: 1fr; margin-top: 8px; }
@media (min-width: 700px) { .t-links { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); } }
.t-linkcard {
  display: block; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--t-line);
  background: #fff; text-decoration: none; color: inherit; min-height: 44px;
}
.t-linkcard:hover { background: var(--lw-bg-warm, #FFF0E8); border-color: var(--lw-primary, #F28B6E); }
.t-linkcard b { display: block; font-family: var(--lw-font-display, system-ui); font-size: 1rem; }
.t-linkcard span { display: block; font-size: .86rem; color: var(--t-muted); margin-top: 2px; line-height: 1.45; }

.t-foot { margin-top: 32px; font-size: .85rem; color: var(--t-muted); line-height: 1.6; }
.t-foot a { color: var(--lw-primary-deep, #BE4327); }

.t-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Only ever visible on paper. */
.print-only { display: none; }

/* ---------- print: US Letter, 0.5in, ink-friendly ---------- */
@media print {
  @page { size: Letter portrait; margin: 0.5in; }
  html, body { background: #fff !important; color: #000 !important; }
  body.lw-tools { font-size: 11pt; }
  .no-print, .lw-sitenav, .t-head .t-free, .t-picker, .t-share, .t-status,
  .t-links, .t-foot, .t-cellbar, nav, noscript { display: none !important; }
  .t-wrap { max-width: none; padding: 0; }
  .t-panel { border: 0; padding: 0; margin: 0 0 14pt; background: #fff; }
  .print-only { display: block; }

  .t-printhead { border-bottom: 1pt solid #000; padding-bottom: 6pt; margin-bottom: 12pt; }
  .t-printhead h2 { font-size: 16pt; margin: 0 0 2pt; }
  .t-printhead p { font-size: 9pt; margin: 0; color: #444; }

  .t-board, .t-strip { gap: 10pt; break-inside: avoid; }
  .t-cell {
    border: 1pt solid #000 !important; background: #fff !important; color: #000 !important;
    min-height: 1.55in; break-inside: avoid; border-radius: 6pt;
  }
  .t-cell img { max-height: 1.15in; }
  .t-cell .w { font-size: 13pt; }
  .t-cell--empty { border-style: dashed !important; }

  .t-table { font-size: 9.5pt; }
  .t-table th, .t-table td { border-bottom: .5pt solid #999; padding: 5pt 6pt; }
  .t-table th { color: #000; }
  tr, .t-linkcard, .t-plan-block { break-inside: avoid; }

  a { color: #000; text-decoration: none; }
  a[data-print-url]::after { content: " (" attr(data-print-url) ")"; font-size: 8.5pt; color: #444; }
  /* Controls do not print. A board or schedule cell is ALSO a <button> and is
     the entire artifact, so it is explicitly exempt — a blanket button rule
     here printed a page with a title and nothing under it. */
  .t-btn, .t-chip, .t-iconbtn, .t-input, .t-select,
  button:not(.t-cell) { display: none !important; }
}
