/* TeacherTimers — shared layout and components used by every tool. */

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--ui-font);
  color: var(--ui);
  background: #fbfaf7;
  min-height: 100vh;
}
body.fs { background: #000; }
body.preload *, body.preload *::before, body.preload *::after { transition: none !important; }

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }

#fx, #confetti {
  inset: 0; width: 100%; height: 100%;
  pointer-events: none;
}
#fx { position: absolute; z-index: 0; }
#confetti { position: fixed; z-index: 50; }
.topbar, .clock-wrap, .controls { position: relative; z-index: 1; }
/* The top bar (and its Tools menu dropdown) must sit above the page content below it,
   or the dropdown shows but clicks land on the content underneath. */
.topbar { z-index: 20; }

#stage {
  position: relative;
  z-index: 1;
  height: 100vh;
  height: 100svh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  color: var(--ui);
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

/* ---------- Top bar ---------- */

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  transition: opacity .4s;
}
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--ui); text-decoration: none;
  font-weight: 800; font-size: 1.2rem; letter-spacing: -.01em;
}
.brand svg { width: 26px; height: 26px; color: var(--accent); }
.brand b { color: var(--accent); font-weight: 800; }
.top-actions { display: flex; gap: 8px; }

/* Tools menu (next to the logo) */
.brand-wrap { display: flex; align-items: center; gap: 14px; }
.tools-menu { position: relative; }
.tools-menu summary { list-style: none; cursor: pointer; }
.tools-menu summary::-webkit-details-marker { display: none; }
.tools-list {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 30;
  min-width: 240px; padding: 8px;
  border-radius: 18px;
  background: var(--sheet); color: var(--sheet-ink);
  box-shadow: 0 20px 50px -15px rgba(0,0,0,.5);
  display: grid; gap: 2px;
}
.tools-list a, .tools-list .soon {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 12px;
  color: inherit; text-decoration: none;
}
.tools-list svg { width: 22px; height: 22px; flex: none; color: var(--accent); }
.tools-list b { display: block; font-weight: 800; }
.tools-list small { display: block; font-size: .8rem; opacity: .7; }
.tools-list a:hover { background: rgba(127,127,127,.14); }
.tools-list a[aria-current="page"] { background: rgba(127,127,127,.12); }
.tools-list .soon { opacity: .55; cursor: default; }
@media (max-width: 480px) { .brand span { display: none; } }
/* medium screens: top-bar buttons show icons only (labels stay as tooltips) so nothing wraps */
@media (max-width: 1080px) {
  .top-actions .icon-btn span { display: none; }
  .top-actions .icon-btn { padding: 10px 12px; }
}
.icon-btn span { white-space: nowrap; }

.icon-btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 0; border-radius: var(--radius);
  background: var(--surface);
  padding: 10px 16px;
  font-weight: 700; font-size: .95rem;
  color: var(--ui);
  transition: background .15s, transform .1s;
}
.icon-btn:hover { background: var(--surface-hover); }
.icon-btn:active { transform: scale(.96); }
.icon-btn svg { width: 20px; height: 20px; }


/* ---------- Controls ---------- */

.controls {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding-top: 8px;
  transition: opacity .4s, transform .4s;
}
.row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }

.btn {
  border: 0;
  border-radius: var(--radius);
  padding: 14px 26px;
  min-width: 108px;
  font-weight: 800; font-size: 1.15rem;
  background: var(--surface);
  color: var(--ui);
  transition: background .15s, transform .1s, filter .15s;
}
.btn:hover { background: var(--surface-hover); }
.btn:active { transform: scale(.96); }
.btn.primary {
  background: var(--accent); color: var(--accent-ink);
  min-width: 170px; font-size: 1.3rem;
  box-shadow: 0 6px 20px -8px rgba(0,0,0,.5);
}
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.ghost { background: transparent; box-shadow: inset 0 0 0 2px var(--surface-hover); }
.btn.ghost:hover { background: var(--surface); }

.chip {
  border: 0;
  border-radius: var(--radius);
  padding: 9px 16px;
  min-width: 56px;
  font-weight: 800; font-size: 1rem;
  background: var(--surface);
  color: var(--ui);
  transition: background .15s, transform .1s;
}
.chip:hover { background: var(--surface-hover); }
.chip:active { transform: scale(.94); }
.chip.active { background: var(--accent); color: var(--accent-ink); }
.chip.small { padding: 7px 13px; font-size: .92rem; min-width: 0; }
.chip.solid { background: var(--accent); color: var(--accent-ink); }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- Idle + full screen ---------- */

body.idle { cursor: none; }
body.idle .topbar,
body.idle .controls { opacity: 0; pointer-events: none; }
body.idle .controls { transform: translateY(12px); }

body.fs .about { display: none; }
body.fs .topbar {
  position: absolute; top: max(12px, env(safe-area-inset-top)); left: 16px; right: 16px; z-index: 20;
}
body.fs .controls {
  position: absolute; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); z-index: 5;
  transform: translateX(-50%);
  width: max-content; max-width: calc(100% - 32px);
  padding: 14px 18px;
  border-radius: 28px;
  background: var(--sheet);
  color: var(--sheet-ink);
  box-shadow: 0 20px 50px -20px rgba(0,0,0,.6);
}
body.fs.idle .controls { transform: translate(-50%, 16px); }
body.fs #fullscreenBtn span { display: none; }

/* ---------- Settings sheet ---------- */

dialog {
  border: 0; padding: 0;
  border-radius: 24px;
  width: min(680px, calc(100% - 24px));
  max-height: calc(100% - 24px);
  background: var(--sheet);
  color: var(--sheet-ink);
  box-shadow: 0 30px 80px -20px rgba(0,0,0,.6);
}
dialog::backdrop { background: rgba(0,0,0,.45); backdrop-filter: blur(3px); }
dialog[open] { animation: rise .25s ease-out; }
@keyframes rise { from { transform: translateY(20px); opacity: 0; } }

.sheet { padding: 22px 24px 24px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet h2 { margin: 0; font-size: 1.4rem; font-weight: 800; }
.sheet h3 { margin: 22px 0 10px; font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; opacity: .7; }
.sheet .close { padding: 8px 12px; font-size: 1rem; color: var(--sheet-ink); }

.theme-group { margin: 14px 0 8px; font-size: .95rem; font-weight: 800; }
.theme-group:first-child { margin-top: 0; }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.theme-card {
  position: relative;
  border: 0; padding: 0; overflow: hidden;
  border-radius: 16px;
  aspect-ratio: 16 / 10;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-shadow: inset 0 0 0 1px rgba(127,127,127,.25);
  transition: transform .12s;
}
.theme-card:hover { transform: translateY(-2px); }
.theme-card .num { font-size: 1.9rem; line-height: 1; }
.theme-card .name {
  position: absolute; left: 8px; bottom: 6px;
  font-family: var(--ui-font); font-weight: 800; font-size: .78rem;
  padding: 2px 8px; border-radius: 99px; background: rgba(0,0,0,.45); color: #fff;
}
.theme-card[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--sheet), 0 0 0 6px var(--accent); }

.sound-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.sound-grid .chip { background: rgba(127,127,127,.15); color: var(--sheet-ink); }
.sheet .sound-grid .chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.sound-hint { margin: 10px 0 0; font-size: .85rem; opacity: .75; line-height: 1.45; }

.toggle { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-weight: 700; cursor: pointer; }
.toggle input { width: 20px; height: 20px; accent-color: var(--accent); }

.sheet-foot { margin-top: 22px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.muted { opacity: .7; font-size: .9rem; }

/* ---------- Tabs, steps and code boxes inside sheets ---------- */

.sheet .lead { margin: 8px 0 0; }
.sheet p { line-height: 1.5; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 18px 0 6px; padding: 4px; border-radius: 16px; background: rgba(127,127,127,.12); }
.tab {
  flex: 1 1 auto; border: 0; border-radius: 12px; padding: 9px 12px;
  background: transparent; color: var(--sheet-ink); font-weight: 800; font-size: .95rem;
}
.tab small { font-size: .7rem; font-weight: 800; opacity: .7; margin-left: 4px; text-transform: uppercase; letter-spacing: .04em; }
.tab[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
.tabpanel { padding-top: 6px; }
.chip.big { padding: 12px 20px; font-size: 1rem; }
.sheet .chip:not(.solid) { background: rgba(127,127,127,.15); color: var(--sheet-ink); }
.chip:disabled { opacity: .6; cursor: progress; }
.steps { margin: 14px 0 0; padding-left: 1.3em; line-height: 1.55; }
.steps li { margin: 4px 0; }
.steps li::marker { font-weight: 800; color: var(--accent); }
.sheet kbd { background: rgba(127,127,127,.15); border-color: rgba(127,127,127,.35); color: var(--sheet-ink); }
.code {
  width: 100%; margin-top: 8px; resize: vertical;
  font: 600 .85rem/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  padding: 12px; border-radius: 12px; border: 1px solid rgba(127,127,127,.3);
  background: rgba(127,127,127,.08); color: var(--sheet-ink);
}

/* ---------- Embedded (iframe) mode ---------- */

body.embed .about { display: none; }
body.embed #slidesBtn, body.embed .brand span, body.embed .tools-menu { display: none; }
body.embed #stage { padding: 8px 10px 10px; }
body.embed .icon-btn { padding: 7px 10px; }
body.embed .icon-btn span { display: none; }

/* ---------- Toast ---------- */

.toast {
  position: fixed; left: 50%; top: 20px; z-index: 60;
  transform: translate(-50%, -150%);
  padding: 10px 18px; border-radius: 99px;
  background: #111; color: #fff; font-weight: 700;
  box-shadow: 0 10px 30px -10px rgba(0,0,0,.5);
  transition: transform .3s;
}
.toast.show { transform: translate(-50%, 0); }

/* ---------- About (below the fold) ---------- */

.about {
  position: relative; z-index: 1;
  background: #fbfaf7;
  color: #1f2937;
}
.about-inner { max-width: 960px; margin: 0 auto; padding: 64px 20px 40px; }
.about h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); margin: 0 0 12px; letter-spacing: -.02em; }
.about h2 { font-size: 1.25rem; margin: 36px 0 12px; }
.about p { line-height: 1.6; font-size: 1.05rem; color: #374151; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-top: 28px; }
.cards section { background: #fff; border-radius: 18px; padding: 4px 20px 12px; box-shadow: 0 1px 0 rgba(0,0,0,.05), 0 8px 24px -16px rgba(0,0,0,.25); }
.cards h2 { margin-top: 18px; }
.keys { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 8px 24px; margin: 0; }
.keys div { display: flex; align-items: baseline; gap: 12px; padding: 6px 0; border-bottom: 1px solid #ece9e2; }
.keys dt { min-width: 92px; }
.keys dd { margin: 0; color: #4b5563; }
kbd {
  display: inline-block; min-width: 1.6em; text-align: center;
  font-family: var(--ui-font); font-weight: 800; font-size: .85em;
  padding: 2px 6px; border-radius: 6px;
  background: #fff; border: 1px solid #d6d3cc; border-bottom-width: 3px;
}
.about footer { text-align: center; padding: 28px 20px 40px; color: #6b7280; font-size: .9rem; }

/* ---------- Small screens ---------- */

@media (max-width: 640px) {
  .brand-wrap { gap: 8px; }
  .top-actions { gap: 6px; }
  .icon-btn span { display: none; }
  .icon-btn { padding: 10px 12px; }
  .btn { padding: 12px 16px; min-width: 0; font-size: 1rem; }
  .btn.primary { min-width: 120px; font-size: 1.1rem; }
  .chip { padding: 8px 12px; min-width: 0; font-size: .92rem; }
  .controls { gap: 10px; }
  .tab small { display: none; }
}
@media (max-height: 560px) and (min-width: 641px) {
  .controls { gap: 6px; }
  .btn { padding: 10px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- Pro links (Tools menu, timer info section, picker panel) ---------- */

.tools-list .badge {
  font-style: normal; font-size: .65rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
  padding: 2px 6px; margin-left: 4px; border-radius: 99px; vertical-align: 2px;
  background: var(--accent); color: var(--accent-ink);
}
.pro-teaser {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px;
  margin: 32px 0 8px; padding: 18px 22px;
  border-radius: 18px;
  background: linear-gradient(135deg, #eef2ff, #fdf4ff);
  box-shadow: inset 0 0 0 1px rgba(99, 102, 241, .18);
}
.pro-teaser b { display: block; font-size: 1.1rem; margin-bottom: 4px; }
.pro-teaser span { color: #4b5563; line-height: 1.5; }
.pro-teaser > div { flex: 1 1 320px; }
.pro-teaser-btn {
  flex: none; padding: 11px 20px; border-radius: 99px;
  background: #4f46e5; color: #fff; font-weight: 800; text-decoration: none;
}
.pro-teaser-btn:hover { filter: brightness(1.1); }
.pro-nudge {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 10px 12px; border-radius: 14px;
  background: rgba(127,127,127,.12); color: inherit;
  font-size: .85rem; font-weight: 700; line-height: 1.4; text-decoration: none;
}
.pro-nudge:hover { background: rgba(127,127,127,.22); }
.pro-nudge svg { width: 16px; height: 16px; flex: none; margin-top: 1px; color: var(--accent); }
.about footer a { color: inherit; }

/* ---------- Landing-page copy and "Popular timers" links (info section) ---------- */

.about .lead { font-size: 1.15rem; }
.about .ideas { line-height: 1.7; color: #374151; padding-left: 1.3em; }
.about .ideas li::marker { color: #6366f1; font-weight: 800; }
.about .faq { display: grid; gap: 12px; margin: 0 0 8px; }
.about .faq div { background: #fff; border-radius: 16px; padding: 14px 18px; box-shadow: 0 1px 0 rgba(0,0,0,.04); }
.about .faq dt { font-weight: 800; margin-bottom: 4px; }
.about .faq dd { margin: 0; color: #4b5563; line-height: 1.55; }
.about .cta {
  border: 0; border-radius: 99px; padding: 13px 24px;
  background: #4f46e5; color: #fff; font-weight: 800; font-size: 1.05rem;
}
.about .cta:hover { filter: brightness(1.1); }
.popular {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 8px 28px;
  margin-top: 40px; padding-top: 24px; border-top: 1px solid #ece9e2;
}
.popular h2 { font-size: 1rem; margin: 0 0 8px; }
.popular p { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.popular a {
  padding: 5px 11px; border-radius: 99px;
  background: #fff; color: #374151; text-decoration: none; font-weight: 700; font-size: .9rem;
  box-shadow: inset 0 0 0 1px #e5e2da;
}
.popular a:hover { background: #eef2ff; color: #4338ca; box-shadow: inset 0 0 0 1px #c7d2fe; }

/* ---------- Music panel ---------- */

#musicVolume { width: 100%; accent-color: var(--accent); height: 28px; }
#musicBtn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
