/* Brave New Word — styles match b0y.eu (reset, theme vars, components) */

/* ===== reset ===== */
*, ::before, ::after { box-sizing: border-box; border: 0 solid currentColor; }
html, body { margin: 0; padding: 0; }
h1, h2, p, ul, figure { margin: 0; padding: 0; }
ul { list-style: none; }
a { color: inherit; text-decoration: inherit; }
button { background: none; font: inherit; color: inherit; cursor: pointer; padding: 0; }
img { display: block; max-width: 100%; height: auto; }
input, select, textarea, output { margin: 0; font: inherit; color: inherit; }

/* ===== theme (same variables + storage key as b0y.eu) ===== */
[data-theme="black"] { --bg: #000; --fg: #fff; --sec: #e5e5e5; }
[data-theme="lofi"]  { --bg: #fff; --fg: #000; --sec: #1a1a1a; }
body {
  background-color: var(--bg);
  color: var(--fg);
  font-family: system-ui, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== layout ===== */
header { text-align: center; padding: 2.5rem 1rem 1rem; }
header h1 {
  font-size: 1.875rem; line-height: 2.25rem; font-weight: 800;
  letter-spacing: -0.025em; position: relative; display: inline-block;
}
header h1 .badge { position: absolute; top: -1rem; left: 100%; margin-left: 0.5rem; font-weight: 300; }
header h2 { font-size: 1.125rem; line-height: 1.75rem; font-weight: 400; margin-top: 0.5rem; }
main { width: 95vw; max-width: 48rem; margin: 0 auto; flex: 1 1 auto; padding: 0.5rem 0 1rem; }
footer { display: flex; justify-content: center; padding: 1rem; font-size: 0.875rem; font-weight: 300; }

.text-secondary { color: var(--sec); }
.hidden { display: none !important; }
.icon { display: inline-block; vertical-align: middle; fill: currentColor; flex-shrink: 0; }
.w-4 { width: 1rem; } .h-4 { height: 1rem; }

/* ===== components from b0y.eu ===== */
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 1.9rem; border: 1px solid currentColor;
  padding: 0 0.563rem; height: 1.25rem; width: fit-content;
  font-size: 0.875rem; line-height: 1.25rem; white-space: nowrap;
}
.badge-outline { border-color: currentColor; background-color: transparent; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.5rem; height: 3rem; min-height: 3rem; padding: 0 1.25rem;
  border-radius: 0.5rem; font-size: 0.875rem; font-weight: 600;
  user-select: none;
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}
.btn-outline { border: 1px solid currentColor; background-color: transparent; }
.btn-outline:hover:not(:disabled) { background-color: var(--fg); color: var(--bg); border-color: var(--fg); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.card { position: relative; display: flex; flex-direction: column; border-radius: 1rem; overflow: visible; }
.card-bordered { border-width: 1px; border-color: var(--sec); }
.card-body { display: flex; flex-direction: column; flex: 1 1 auto; gap: 0.75rem; padding: 1rem; }

.collapse { position: relative; display: flex; flex-direction: column; width: 100%; border-radius: 1rem; }
.collapse > input[type="checkbox"] {
  appearance: none; -webkit-appearance: none;
  position: absolute; top: 0; left: 0; width: 100%; height: 3.75rem;
  opacity: 0; cursor: pointer; z-index: 1;
}
.collapse-title {
  position: relative; min-height: 3.75rem; padding: 1rem 3rem 1rem 1rem;
  width: 100%; font-weight: 800; letter-spacing: -0.025em; font-size: 1.25rem;
}
.collapse-arrow > .collapse-title::after {
  content: ""; position: absolute; top: 1.9rem; right: 1.4rem;
  height: 0.5rem; width: 0.5rem; box-shadow: 2px 2px;
  transform: translateY(-100%) rotate(45deg);
  transition: transform 0.25s ease; pointer-events: none;
}
.collapse-arrow > input:checked ~ .collapse-title::after {
  transform: translateY(-50%) rotate(225deg);
}
.collapse-content {
  max-height: 0; overflow: hidden; padding: 0 1rem;
  transition: max-height 0.7s cubic-bezier(0.4, 0, 0.2, 1), padding 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}
.collapse > input:checked ~ .collapse-content { max-height: 9999px; padding-bottom: 1rem; overflow: visible; }

.toggle {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  border-radius: 9999px; border: 1px solid var(--sec);
  background-color: var(--sec);
  --tglbg: var(--bg); --handleoffset: 0.75rem;
  box-shadow: calc(var(--handleoffset) * -1) 0 0 2px var(--tglbg) inset,
              0 0 0 2px var(--tglbg) inset;
  transition: box-shadow 0.2s;
  flex-shrink: 0;
}
.toggle:checked {
  box-shadow: var(--handleoffset) 0 0 2px var(--tglbg) inset,
              0 0 0 2px var(--tglbg) inset;
}
.toggle-sm { width: 2rem; height: 1.25rem; }

.link { text-decoration: underline; cursor: pointer; }
.link-hover { text-decoration: none; }
.link-hover:hover { text-decoration: underline; }

.prose p { margin: 0.75em 0; font-size: 0.95rem; }
.prose p:first-child { margin-top: 0; }

.theme-corner {
  display: flex; align-items: center; gap: 0.25rem;
  position: absolute; top: 1rem; right: 1rem; z-index: 10;
}
@media (min-width: 768px) { .theme-corner { top: 1.5rem; right: 1.5rem; } }

/* ===== bnw-specific ===== */
.words {
  display: flex; flex-wrap: wrap; gap: 0.5rem;
  min-height: 6rem; align-content: flex-start;
}
.chip {
  display: inline-flex; align-items: center; gap: 0.15rem;
  border: 1px solid var(--sec); border-radius: 0.5rem;
  padding-right: 0.35rem;
}
.word {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.125rem; padding: 0.3rem 0.5rem 0.3rem 0.8rem;
  border-radius: 0.5rem 0 0 0.5rem;
  transition: background-color 0.15s, color 0.15s;
}
.word:hover, .word.copied { background-color: var(--fg); color: var(--bg); }
.chipbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.4rem; height: 1.4rem; border-radius: 0.35rem;
  color: var(--sec); font-size: 0.85rem; line-height: 1;
}
.chipbtn:hover { color: var(--fg); }
.no-tts .speakbtn { display: none; }

.bank-section { border-bottom: 1px solid var(--sec); padding-bottom: 0.75rem; }
.bank-head { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; }
.bank-title { font-weight: 800; letter-spacing: -0.025em; }
.words-bank { min-height: 0; }
.minibtn {
  border: 1px solid var(--sec); border-radius: 0.35rem;
  font-size: 0.75rem; padding: 0.1rem 0.5rem; color: var(--sec);
}
.minibtn:hover { background-color: var(--fg); color: var(--bg); border-color: var(--fg); }

.status { font-size: 0.875rem; min-height: 1.25rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.controls { display: flex; flex-direction: column; gap: 0.75rem; padding: 1rem; }
.ctl { display: grid; grid-template-columns: 11rem minmax(0, 1fr) auto; gap: 0.75rem; align-items: center; }
.ctl label { font-weight: 600; font-size: 0.95rem; }
.ctl .pair { display: flex; align-items: center; gap: 0.5rem; }

select, input[type="text"], input[type="number"], textarea {
  background-color: transparent; border: 1px solid var(--sec);
  border-radius: 0.5rem; padding: 0.45rem 0.6rem; width: 100%;
  font-size: 0.95rem;
}
select { appearance: auto; background-color: var(--bg); }
select option { background-color: var(--bg); color: var(--fg); }
input[type="number"] { width: 5rem; }
textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  resize: vertical;
}
input[type="range"] { accent-color: var(--fg); width: 100%; max-width: 14rem; }
input[type="checkbox"].check {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  width: 1.25rem; height: 1.25rem; border: 1px solid var(--sec);
  border-radius: 0.25rem; justify-self: start; position: relative;
}
input[type="checkbox"].check:checked::after {
  content: ""; position: absolute; inset: 2px 5px 5px 2px;
  border-right: 2px solid var(--fg); border-bottom: 2px solid var(--fg);
  transform: translate(2px, -1px) rotate(45deg);
}
input[type="checkbox"].check:disabled { opacity: 0.35; cursor: not-allowed; }
output { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; min-width: 3ch; }

/* tooltip */
.tip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.15rem; height: 1.15rem; border: 1px solid var(--sec);
  border-radius: 9999px; font-size: 0.75rem; color: var(--sec);
  cursor: help; position: relative; user-select: none; flex-shrink: 0;
}
.tip .tipbox {
  display: none; position: absolute; bottom: 140%; right: -0.5rem;
  width: min(18rem, 75vw); background-color: var(--bg);
  border: 1px solid var(--sec); border-radius: 0.5rem;
  padding: 0.6rem 0.8rem; font-size: 0.875rem; line-height: 1.35;
  color: var(--fg); text-align: left; z-index: 30; cursor: auto;
}
.tip .tipbox code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--sec);
}
.tip:hover .tipbox, .tip:focus .tipbox, .tip:focus-within .tipbox { display: block; }

/* ===== responsive / a11y ===== */
@media (max-width: 640px) {
  .ctl { grid-template-columns: 1fr auto; }
  .ctl label { grid-column: 1 / -1; margin-bottom: -0.4rem; }
  header h1 .badge { position: static; margin-left: 0.5rem; vertical-align: middle; }
}
@media only screen and (max-width: 480px) {
  * { font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after { transition: none !important; animation: none !important; }
}
