/* ui.css — pad, tools, chips, overlays, cards, tiles, loader. */

/* ---- chips -------------------------------------------------------------- */

.chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px 4px;
  border: 1px solid var(--line);
  border-radius: 100px;
  background: var(--panel);
  color: var(--chalk-dim);
  white-space: nowrap;
}

.chip-band { color: var(--brass); border-color: var(--brass-line); }

/* ---- number pad --------------------------------------------------------- */

.pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.pad-n16 { grid-template-columns: repeat(4, 1fr); }
.pad-n4 { grid-template-columns: repeat(2, 1fr); }

.pad-key {
  position: relative;
  aspect-ratio: 1 / 0.86;
  display: grid;
  place-items: center;
  background: var(--plate);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--chalk);
  cursor: pointer;
  transition: background 0.13s, border-color 0.13s, transform 0.08s, color 0.13s;
}
.pad-key:hover { background: var(--plate-2); border-color: var(--plate-3); }
.pad-key:active { transform: translateY(1px); }

.pad-digit {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums lining-nums;
  font-size: clamp(20px, 4.4vw, 26px);
  line-height: 1;
  font-weight: 500;
}

.pad-left {
  position: absolute;
  right: 7px;
  bottom: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--chalk-faint);
}

.pad.dim-done .pad-key.is-done { opacity: 0.38; }
.pad.dim-done .pad-key.is-done .pad-left { display: none; }

/* Pencil-mark mode shows the digit where it would sit in the cell's marks. */
.pad.is-notes .pad-key { background: var(--ground-2); border-style: dashed; }
.pad.is-notes .pad-digit { font-size: clamp(15px, 3.2vw, 19px); color: var(--chalk-dim); }

/* ---- tools -------------------------------------------------------------- */

.tools {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 10px 4px 8px;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--chalk-dim);
  cursor: pointer;
  transition: background 0.13s, color 0.13s, border-color 0.13s;
}
.tool svg { width: 19px; height: 19px; }
.tool:hover:not(:disabled) { background: var(--plate); color: var(--chalk); }
.tool:disabled { opacity: 0.32; cursor: default; }
.tool.is-active {
  color: var(--brass);
  border-color: var(--brass);
  background: var(--plate);
}
.tool-label { color: inherit; }

/* ---- buttons ------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--plate);
  color: var(--chalk);
  font-family: var(--font-ui);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.055em;
  cursor: pointer;
  transition: background 0.14s, border-color 0.14s, color 0.14s;
}
.btn:hover { background: var(--plate-2); border-color: var(--plate-3); }

.btn-primary {
  background: var(--brass);
  border-color: var(--brass);
  color: #1a1206;
}
.btn-primary:hover { background: var(--brass-bright); border-color: var(--brass-bright); }
[data-theme="light"] .btn-primary { color: #fff; }

.btn-ghost { background: none; }
.btn-ghost:hover { background: var(--plate); }
.btn-danger { color: var(--coral); border-color: transparent; background: none; }
.btn-danger:hover { background: var(--coral-soft); }
.btn-sm { padding: 7px 12px; font-size: 12px; }
.btn-block { width: 100%; }

/* ---- more menu ---------------------------------------------------------- */

.menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  right: 0;
  display: none;
  flex-direction: column;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  z-index: 40;
}
.menu.is-open { display: flex; }
.menu button {
  text-align: left;
  padding: 9px 11px;
  background: none;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--chalk-dim);
  font-size: 13.5px;
  cursor: pointer;
}
.menu button:hover { background: var(--plate); color: var(--chalk); }

/* ---- hint panel --------------------------------------------------------- */

.hint {
  padding: 14px 15px 13px;
  background: var(--panel);
  border: 1px solid var(--brass-line);
  border-radius: var(--radius);
}
.hint-name {
  font-family: var(--font-ui);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--brass);
  margin-bottom: 6px;
}
.hint-text { font-size: 13.5px; color: var(--chalk-dim); line-height: 1.55; }
.hint-actions { display: flex; gap: 8px; margin-top: 12px; }

/* ---- overlay and sheets -------------------------------------------------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
  padding: clamp(12px, 4vw, 40px);
  background: color-mix(in srgb, var(--ground) 82%, transparent);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
}
.overlay.is-open { display: flex; }

.sheet {
  position: relative;
  width: min(100%, 560px);
  max-height: 100%;
  overflow-y: auto;
  padding: clamp(22px, 4vw, 34px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  animation: sheet-in 0.22s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}
.sheet-stats { width: min(100%, 660px); }

@keyframes sheet-in {
  from { opacity: 0; transform: translateY(10px) scale(0.99); }
}

.sheet-head { margin-bottom: 22px; padding-right: 34px; }
.sheet-title { font-size: clamp(23px, 4vw, 29px); line-height: 1.15; }
.sheet-sub { margin-top: 8px; font-size: 13.5px; color: var(--chalk-dim); }
.eyebrow { margin-bottom: 9px; }

.sheet-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: none;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--chalk-faint);
  cursor: pointer;
}
.sheet-close svg { width: 17px; height: 17px; }
.sheet-close:hover { background: var(--plate); color: var(--chalk); }

.sheet-section { margin-bottom: 22px; }
.section-label { display: block; margin-bottom: 11px; }
.sheet-note { font-size: 12.5px; color: var(--chalk-faint); line-height: 1.5; }
.sheet-note + .sheet-section { margin-top: 20px; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 6px; }
.empty { font-size: 13.5px; color: var(--chalk-faint); }

/* ---- choices ------------------------------------------------------------- */

.choice {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  background: var(--plate);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--chalk-dim);
  font-family: var(--font-ui);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.14s, background 0.14s, color 0.14s;
}
.choice:hover { border-color: var(--plate-3); color: var(--chalk); }
/* Selected state lifts the plate and puts the brass on the edge — a brass
   wash over this cold ground turns olive. */
.choice.is-on {
  border-color: var(--brass);
  background: var(--plate-2);
  color: var(--chalk);
}

.choice-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.choice-row { display: flex; gap: 8px; flex-wrap: wrap; }
.choice-list { display: flex; flex-direction: column; gap: 8px; }

.choice-variant { flex-direction: column; gap: 8px; padding: 12px 6px 10px; text-align: center; }
.vmark { width: 30px; height: 30px; fill: none; stroke: var(--chalk-faint); stroke-width: 1.3; }
.vmark .accent { stroke: var(--brass); }
.vmark .dash { stroke-dasharray: 3 2.5; }
.vmark .fill { fill: var(--brass); opacity: 0.3; stroke: none; }
.choice.is-on .vmark { stroke: var(--chalk-dim); }
.choice-name { display: block; }
.choice-size { justify-content: center; min-width: 78px; }

.choice-diff { align-items: flex-start; }
.choice-text { display: flex; flex-direction: column; gap: 3px; }
.choice-blurb {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 12.5px;
  letter-spacing: 0;
  color: var(--chalk-faint);
}

/* Difficulty drawn as clue density — the harder the band, the emptier. */
.density {
  display: grid;
  grid-template-columns: repeat(3, 4px);
  gap: 2px;
  flex: none;
  margin-top: 3px;
}
.density i {
  width: 4px;
  height: 4px;
  border-radius: 1px;
  background: var(--line);
}
.density i.on { background: var(--brass); }

/* ---- home cards ---------------------------------------------------------- */

.home { display: flex; flex-direction: column; gap: 10px; }

.card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 17px 18px;
  background: var(--plate);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.card:hover { border-color: var(--brass-line); background: var(--plate-2); }
.card-title { font-family: var(--font-ui); font-size: 18px; font-weight: 600; }
.card-meta { font-size: 12.5px; color: var(--chalk-faint); }
.card-resume { border-color: var(--brass-line); }
.card-daily.is-done .card-title { color: var(--jade); }

.home-links { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

/* ---- tiles and tables ----------------------------------------------------- */

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 9px;
  margin-bottom: 22px;
}
.tile {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 14px 15px;
  background: var(--plate);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.tile-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 23px;
  line-height: 1.1;
}
.tile-sub { font-size: 11.5px; color: var(--chalk-faint); }

.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; max-width: 260px; }
.cal-day {
  aspect-ratio: 1;
  border-radius: 3px;
  background: var(--plate);
  border: 1px solid var(--line);
}
.cal-day.is-done { background: var(--brass); border-color: var(--brass); }

.table { display: flex; flex-direction: column; gap: 1px; }
.table-row {
  display: grid;
  grid-template-columns: 1fr 60px 72px 78px;
  gap: 8px;
  padding: 9px 2px;
  font-size: 13px;
  border-bottom: 1px solid var(--line);
}
.table-head { color: var(--chalk-faint); font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; }
.table-name { color: var(--chalk-dim); }

.ach-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; }
.ach {
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  opacity: 0.42;
}
.ach.is-earned { opacity: 1; border-color: var(--brass-line); background: var(--plate); }
.ach.is-earned .ach-name { color: var(--brass); }
.ach.is-new { animation: sheet-in 0.4s ease both; }
.ach-name { display: block; font-family: var(--font-ui); font-weight: 600; font-size: 13.5px; }
.ach-desc { display: block; font-size: 12px; color: var(--chalk-faint); margin-top: 2px; }

/* ---- settings and help ----------------------------------------------------- */

.toggle-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.toggle-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.toggle-label { font-size: 14px; }
.toggle-desc { font-size: 12px; color: var(--chalk-faint); }
.toggle-input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-track {
  flex: none;
  width: 40px;
  height: 23px;
  border-radius: 100px;
  background: var(--plate-2);
  border: 1px solid var(--line);
  position: relative;
  transition: background 0.16s, border-color 0.16s;
}
.toggle-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--chalk-faint);
  transition: transform 0.16s, background 0.16s;
}
.toggle-input:checked ~ .toggle-track { background: var(--brass-soft); border-color: var(--brass); }
.toggle-input:checked ~ .toggle-track::after { transform: translateX(17px); background: var(--brass); }
.toggle-input:focus-visible ~ .toggle-track { outline: 2px solid var(--brass); outline-offset: 2px; }

.help p { font-size: 13.5px; color: var(--chalk-dim); line-height: 1.6; }
.help-list { display: flex; flex-direction: column; }
.help-row {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.help-term { color: var(--chalk); font-weight: 500; }
kbd.help-term {
  font-size: 12px;
  color: var(--brass);
  background: none;
  padding: 0;
}
.help-def { color: var(--chalk-faint); }

/* ---- loader ---------------------------------------------------------------- */

.loader {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: color-mix(in srgb, var(--ground) 90%, transparent);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.loader.is-on { display: flex; }

.loader-inner { width: min(100%, 330px); text-align: center; }

/* The mark is a 3x3 of cells lighting in sequence — the same fractal the
   board and the pencil marks are built from. */
.loader-mark {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  width: 62px;
  margin: 0 auto 20px;
}
.loader-mark i {
  aspect-ratio: 1;
  border-radius: 2px;
  background: var(--plate-2);
  animation: mark-blink 1.8s ease-in-out infinite;
}
.loader-mark i:nth-child(1) { animation-delay: 0s; }
.loader-mark i:nth-child(2) { animation-delay: 0.12s; }
.loader-mark i:nth-child(3) { animation-delay: 0.24s; }
.loader-mark i:nth-child(4) { animation-delay: 0.36s; }
.loader-mark i:nth-child(5) { animation-delay: 0.48s; }
.loader-mark i:nth-child(6) { animation-delay: 0.6s; }
.loader-mark i:nth-child(7) { animation-delay: 0.72s; }
.loader-mark i:nth-child(8) { animation-delay: 0.84s; }
.loader-mark i:nth-child(9) { animation-delay: 0.96s; }

@keyframes mark-blink {
  0%, 60%, 100% { background: var(--plate-2); }
  25% { background: var(--brass); }
}

.loader-text { font-family: var(--font-ui); font-size: 15px; letter-spacing: 0.04em; }

.loader-bar {
  height: 3px;
  margin: 15px 0 12px;
  background: var(--plate-2);
  border-radius: 2px;
  overflow: hidden;
}
.loader-bar span {
  display: block;
  height: 100%;
  width: 8%;
  background: var(--brass);
  transition: width 0.3s ease;
}

.loader-note { font-size: 12px; color: var(--chalk-faint); line-height: 1.5; }

/* ---- small screens ---------------------------------------------------------- */

@media (max-width: 900px) {
  /* A square key on a phone is taller than the board it sits under. */
  .pad-key { aspect-ratio: 1 / 0.58; }
  .pad-n16 .pad-key { aspect-ratio: 1 / 0.72; }
  .pad-digit { font-size: 23px; }
  .tool { padding: 8px 4px 6px; }
}

@media (max-width: 560px) {
  .choice-grid { grid-template-columns: repeat(3, 1fr); }
  .table-row { grid-template-columns: 1fr 44px 60px 62px; font-size: 12px; }
  .help-row { grid-template-columns: 110px 1fr; }
  /* One row of six keeps the board and the controls on a single screen. */
  .tools { grid-template-columns: repeat(6, 1fr); gap: 4px; }
  .tool { padding: 7px 2px 5px; gap: 4px; }
  .tool svg { width: 17px; height: 17px; }
  .tool-label { font-size: 9px; letter-spacing: 0.06em; }
  .pad { gap: 7px; }
  .pad-key { aspect-ratio: 1 / 0.52; }
}
