/* Crossword player styles — light theme, Merriweather (mid-day.com look).
   All scoped under .cw so the widget is safe to embed anywhere. */

.cw {
  /* theme tokens — retune per host if needed */
  --cw-font: "Merriweather", Georgia, "Times New Roman", serif;
  --cw-bg: #ffffff;
  --cw-ink: #1a1a1a;
  --cw-muted: #6b6b6b;
  --cw-line: #2b2b2b;
  --cw-cell-bg: #ffffff;
  --cw-black: #1a1a1a;
  --cw-highlight: #fde7b0;   /* active word */
  --cw-active: #f5b301;      /* active cell */
  --cw-accent: #c8102e;      /* mid-day red */
  --cw-wrong: #e3342f;
  --cw-correct: #2e7d32;
  --cw-correct-bg: #e6f4e6;
  --cw-revealed: #2a7de1;
  --cw-panel: #faf7f2;
  --cw-border: #e3ded5;

  font-family: var(--cw-font);
  color: var(--cw-ink);
  background: var(--cw-bg);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  /*max-width: 960px;*/
  margin: 0 auto;
  /*padding: 14px;*/
  box-sizing: border-box;
}
.cw *, .cw *::before, .cw *::after { box-sizing: border-box; }

/* header */
.cw-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 2px solid var(--cw-line);
  padding-bottom: 10px;
  margin-bottom: 14px;
}
.cw-title { margin: 0; font-size: 1.3rem; font-weight: 700; }
.cw-author { color: var(--cw-muted); font-size: .8rem; font-style: italic; }
.cw-timer {
  font-variant-numeric: tabular-nums;
  font-size: 1.1rem;
  font-weight: 700;
  background: var(--cw-panel);
  border: 1px solid var(--cw-border);
  border-radius: 8px;
  padding: 4px 10px;
  white-space: nowrap;
}

/* layout */
.cw-body { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.cw-left { flex: 1 1 360px; min-width: 280px; }
.cw-clues { flex: 1 1 320px; display: flex; gap: 22px; flex-wrap: wrap; }
.cw-cluecol { flex: 1 1 160px; min-width: 150px; }

/* active clue banner */
.cw-activeclue {
  min-height: 2.6em;
  background: var(--cw-panel);
  border-left: 4px solid var(--cw-accent);
  border-radius: 4px;
  padding: 8px 10px;
  margin-bottom: 10px;
  font-size: .95rem;
}

/* grid */
.cw-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  grid-template-rows: repeat(var(--n), 1fr);
  gap: 0;
  width: 100%;
  max-width: 520px;
  aspect-ratio: 1 / 1;
  border: 2px solid var(--cw-line);
  background: var(--cw-line);
  outline: none;
  touch-action: manipulation;
}
.cw-cell {
  position: relative;
  background: var(--cw-cell-bg);
  border: .5px solid var(--cw-line);
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  cursor: pointer;
  font-weight: 700;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  line-height: 1;
}
/* hidden input that drives the native keyboard; sits over the active cell */
.cw-input {
  position: absolute;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  text-align: center;
  font: inherit;
  font-size: 16px;            /* >=16px stops iOS zoom-on-focus */
  outline: none;
  z-index: 2;
}
.cw-black { background: var(--cw-black); cursor: default; }
.cw-num {
  position: absolute;
  top: 1px;
  left: 2px;
  font-size: clamp(7px, 1.6vw, 10px);
  font-weight: 400;
  color: var(--cw-muted);
  line-height: 1;
}
.cw-letter {
  font-size: clamp(13px, 3.6vw, 22px);
  text-transform: uppercase;
}
.cw-cell.cw-highlight { background: var(--cw-highlight); }
.cw-cell.cw-active { background: var(--cw-active); }
.cw-cell.cw-wrong .cw-letter { color: var(--cw-wrong); }
.cw-cell.cw-wrong::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(135deg, transparent 46%, var(--cw-wrong) 46%, var(--cw-wrong) 54%, transparent 54%);
  opacity: .35;
}
.cw-cell.cw-revealed .cw-letter { color: var(--cw-revealed); }
/* positive feedback for Check: green tint + corner tick */
.cw-cell.cw-correct { background: var(--cw-correct-bg); }
.cw-cell.cw-correct .cw-letter { color: var(--cw-correct); }
.cw-cell.cw-correct::after {
  content: "\2713";                 /* ✓ */
  position: absolute;
  right: 1px;
  bottom: 0;
  font-size: clamp(7px, 1.7vw, 11px);
  font-weight: 700;
  line-height: 1;
  color: var(--cw-correct);
}
/* keep the active-cell highlight visible even when marked correct */
.cw-cell.cw-correct.cw-active { background: var(--cw-active); }

/* clue lists */
.cw-cluehead {
  margin: 0 0 6px;
  font-size: 1rem;
  border-bottom: 1px solid var(--cw-border);
  padding-bottom: 4px;
}
.cw-cluelist { list-style: none; margin: 0; padding: 0; }
.cw-clue {
  display: flex;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 4px;
  cursor: pointer;
  font-size: .85rem;
}
.cw-clue:hover { background: var(--cw-panel); }
.cw-clue-n { font-weight: 700; min-width: 1.5em; text-align: right; }
.cw-clue.cw-clue-active { background: var(--cw-highlight); }

/* toolbar */
.cw-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--cw-border);
}
.cw-btngroup { display: flex; align-items: center; gap: 6px; }
.cw-btngroup-label { font-size: .78rem; color: var(--cw-muted); text-transform: uppercase; letter-spacing: .04em; }
.cw-btn {
  font-family: inherit;
  font-size: .82rem;
  padding: 6px 12px;
  border: 1px solid var(--cw-line) !important;;
  border-radius: 6px !important;;
  background: #fff !important;;
  color: var(--cw-ink) !important;;
  cursor: pointer !important;;
}
.cw-btn:hover { background: var(--cw-panel) !important; }
.cw-btn:active { transform: translateY(1px) !important; }
.cw-btn-danger { border-color: var(--cw-wrong) !important; color: var(--cw-wrong) !important; }
button.cw-btn {
    margin: 0px !important;
}
/* completion overlay */
.cw-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.cw-overlay.cw-hidden { display: none; }
.cw-overlay-card {
  background: #fff;
  border-radius: 14px;
  padding: 28px 34px;
  text-align: center;
  max-width: 320px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
.cw-overlay-card h3 { margin: 6px 0; font-size: 1.5rem; }
.cw-overlay-emoji { font-size: 2.6rem; }
.cw-overlay-time { color: var(--cw-muted); margin: 4px 0 16px; }

.cw-hidden { display: none; }

/* error box */
.cw-error {
  border: 1px solid var(--cw-wrong);
  background: #fff4f4;
  color: #7a1c1c;
  padding: 14px 16px;
  border-radius: 8px;
}
.cw-error strong { display: block; margin-bottom: 4px; }

/* small screens: clues stack below the grid */
@media (max-width: 640px) {
  .cw { padding: 10px; }
  .cw-body { flex-direction: column; }
  .cw-left, .cw-clues { flex: 1 1 auto; width: 100%; }
  .cw-grid { max-width: 100%; }
}
