/*
  Word Search Maker (word_search_maker/page.html): the form, the preview, the
  print sheets and the copy below the tool. Plain CSS, not built by Tailwind;
  colours come from the site's theme tokens, except the sheets, which are
  always ink on white like paper, in dark mode too. Sheet sizes are container
  units of the sheet, so the preview and both paper sizes print alike.
*/

.ws [hidden] { display: none !important; }

/* ---- Layout and form ---- */
.ws-layout { display: grid; gap: 1.25rem; align-items: start; }
@media (min-width: 64rem) {
  .ws-layout { grid-template-columns: minmax(20rem, 25rem) minmax(0, 1fr); }
  .ws-side { position: sticky; top: 5.5rem; }
}
@media (max-width: 63.99rem) { .ws-side { order: -1; } }
.ws-panel {
  padding: 1.25rem;
  border: 1px solid var(--color-base-300);
  border-radius: var(--r-md);
  background: var(--color-base-100);
}
@media (min-width: 40rem) { .ws-panel { padding: 1.5rem; } }
.ws-form { display: flex; flex-direction: column; gap: 1.15rem; min-width: 0; }
.ws-field { min-width: 0; margin: 0; padding: 0; border: 0; }
.ws-label { display: block; margin-bottom: 0.4rem; padding: 0; font-size: 0.9375rem; font-weight: 600; }
.ws-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.ws-optional { margin-left: 0.25rem; font-size: 0.8125rem; font-weight: 400; color: var(--muted); }
.ws-help { margin: 0.2rem 0 0.6rem; font-size: 0.8125rem; line-height: 1.5; color: var(--muted); }
.ws-help-after { margin: 0.5rem 0 0; }
.ws-help-tight { margin: -0.6rem 0 0; }
.ws-count { font-size: 0.8125rem; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.ws-count.is-warn { color: var(--color-error); }
.ws textarea, .ws input, .ws select { font-size: 1rem; }   /* 16px keeps iOS from zooming in */
.ws textarea { line-height: 1.45; resize: vertical; }
.ws-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; align-items: start; }
.ws-checks { display: flex; flex-wrap: wrap; gap: 0.75rem 1.5rem; }
.ws-check { display: flex; align-items: center; gap: 0.6rem; font-size: 0.9375rem; cursor: pointer; }

/* Segmented choices built from radios, so they work with the keyboard as usual. */
.ws-seg {
  display: grid;
  gap: 0.25rem;
  padding: 0.25rem;
  border-radius: var(--r-sm);
  background: color-mix(in oklab, var(--color-base-content) 7%, transparent);
}
.ws-seg-2 { grid-template-columns: repeat(2, 1fr); }
.ws-seg-3 { grid-template-columns: repeat(3, 1fr); }
.ws-seg label { position: relative; cursor: pointer; }
.ws-seg input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.ws-seg span {
  display: block;
  padding: 0.45rem 0.5rem;
  border-radius: calc(var(--r-sm) - 0.15rem);
  font-size: 0.875rem;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  color: var(--muted);
  transition: background-color 0.15s, color 0.15s;
}
.ws-seg input:checked + span { background: var(--color-base-100); color: var(--color-base-content); box-shadow: 0 1px 2px rgb(0 0 0 / 0.12); }
.ws-seg input:focus-visible + span { outline: 2px solid var(--color-primary); outline-offset: 1px; }

/* ---- Preview and actions ---- */
.ws-side { display: flex; flex-direction: column; gap: 0.9rem; min-width: 0; }
.ws-view { margin: 0; padding: 0; border: 0; max-width: 16rem; }
.ws-stage {
  display: flex;
  justify-content: center;
  padding: clamp(0.75rem, 4vw, 2rem);
  border-radius: var(--r-md);
  background: color-mix(in oklab, var(--color-base-content) 7%, var(--color-base-200));
}
.ws-stage .ws-sheet {
  width: 100%;
  max-width: 34rem;
  aspect-ratio: var(--ratio, 0.755);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.08), 0 10px 28px rgb(0 0 0 / 0.14);
}
.ws-sheet.is-empty { display: grid; place-items: center; color: #6b7280; font-family: Arial, sans-serif; font-size: 0.9375rem; }
.ws-notes { display: flex; flex-direction: column; gap: 0.5rem; }
.ws-notes:empty { display: none; }
.ws-note { margin: 0; padding: 0.65rem 0.9rem; border-radius: var(--r-sm); font-size: 0.875rem; line-height: 1.5; }
.ws-note.is-info { background: color-mix(in oklab, var(--color-base-content) 6%, var(--color-base-100)); }
.ws-note.is-warn, .ws-alert {
  border: 1px solid color-mix(in oklab, var(--color-error) 40%, transparent);
  background: color-mix(in oklab, var(--color-error) 9%, var(--color-base-100));
  color: var(--color-error);
}
.ws-alert { margin-bottom: 1rem; padding: 0.7rem 1rem; border-radius: var(--r-sm); font-size: 0.9rem; }
.ws-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.ws-actions .btn { gap: 0.5rem; }
.ws-set { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.35rem 1rem; font-size: 0.875rem; }
.ws-code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: 0.08em; }
.ws-fine { font-size: 0.8125rem; line-height: 1.5; color: var(--muted); }

/* ---- Sheets (screen preview and print) ---- */
.ws-sheet {
  container-type: inline-size;
  box-sizing: border-box;
  display: flex;
  overflow: hidden;
  background: #fff;
  color: #1b1f2a;
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.ws-sheet-inner { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 6cqw 6.5cqw 4cqw; }
.ws-sheet-head { flex: none; }
.ws-sheet-title { margin: 0; font-size: 6cqw; font-weight: 700; line-height: 1.1; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.ws-sheet-tag { margin: 1cqw 0 0; font-size: 2.3cqw; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: #b42318; }
.ws-sheet-lines { display: flex; gap: 4cqw; margin-top: 3.2cqw; font-size: 2.3cqw; color: #3b4252; }
.ws-sheet-lines span { padding-bottom: 0.6cqw; border-bottom: 0.25cqw solid #1b1f2a; }
.ws-sheet-lines span:first-child { flex: 2; }
.ws-sheet-lines span:last-child { flex: 1; }
.ws-sheet-intro { margin: 3cqw 0 0; font-size: 2.3cqw; line-height: 1.4; color: #3b4252; }
.ws-sheet-grid { flex: 1 1 auto; min-height: 0; margin: 3cqw 0; }
.ws-grid { display: block; width: 100%; height: 100%; }
.ws-grid-frame { fill: none; stroke: #1b1f2a; stroke-width: 0.6; }
.ws-grid-key rect { stroke-width: 0.75; fill-opacity: 0.12; }
.ws-grid-letters { font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; font-weight: 600; fill: #1b1f2a; text-anchor: middle; }
.ws-bank {
  flex: none;
  margin: 0 0 3cqw;
  padding: 0;
  list-style: none;
  columns: var(--cols, 3);
  column-gap: 4cqw;
  font-size: var(--bank-font, 2.4cqw);
  line-height: 1.55;
}
.ws-bank li { break-inside: avoid; overflow-wrap: anywhere; }
.ws-bank li::before {
  content: "";
  display: inline-block;
  width: 0.62em;
  height: 0.62em;
  margin-right: 0.5em;
  border: 1px solid #6b7280;
  border-radius: 0.15em;
  vertical-align: -0.02em;
}
.is-key .ws-bank li::before { display: none; }
.ws-sheet-foot { flex: none; display: flex; justify-content: space-between; gap: 2cqw; font-size: 1.7cqw; color: #6b7280; }

/* ---- Printing: only the sheets ---- */
.ws-print { display: none; }
@media print {
  body.ws-printing > *:not(.ws-print) { display: none !important; }
  html:has(body.ws-printing), body.ws-printing { background: #fff !important; }
  body.ws-printing .ws-print { display: block; }
  .ws-print .ws-sheet { width: var(--sheet-w); height: var(--sheet-h); break-after: page; page-break-after: always; }
  .ws-print .ws-sheet:last-child { break-after: auto; page-break-after: auto; }
}

/* ---- Below the tool ---- */
.ws-table-wrap { overflow-x: auto; border: 1px solid var(--color-base-300); border-radius: var(--r-md); }
.ws-table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; line-height: 1.45; }
.ws-table th, .ws-table td { padding: 0.6rem 0.85rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--color-base-300); }
.ws-table tbody tr:last-child th, .ws-table tbody tr:last-child td { border-bottom: 0; }
.ws-table thead th { font-size: 0.8125rem; font-weight: 600; color: var(--muted); background: color-mix(in oklab, var(--color-base-content) 4%, var(--color-base-100)); }
.ws-table tbody th { font-weight: 600; white-space: nowrap; }
.ws-table td { color: var(--muted); }
.ws-tips { margin-bottom: 0; padding-left: 1.25rem; list-style: disc; }
.ws-tips li + li { margin-top: 0.5rem; }
.ws-themes { display: grid; gap: 0.9rem; margin: 1.25rem 0 0; padding: 0; list-style: none; }
.ws-themes li { display: flex; flex-direction: column; gap: 0.15rem; font-size: 0.9375rem; line-height: 1.5; }
.ws-theme-link { font-weight: 600; text-decoration: underline; text-underline-offset: 0.18em; }
