/* Base styles for Jeevspark game pages: theme colors, large buttons, top bar,
   messages and the caregiver settings dialog. Games add their own styles on top. */
:root {
  --bg: #FBF7EE;
  --text: #1F3326;
  --muted: #3F5547;
  --panel: #FFFFFF;
  --panel-border: #C9D6CC;
  --accent: #005A5E;
  --accent-text: #FFFFFF;
  --focus: #B04E00;
  color-scheme: light;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="contrast"] {
  --bg: #000000;
  --text: #FFFFFF;
  --muted: #F0F0F0;
  --panel: #111111;
  --panel-border: #FFE600;
  --accent: #FFE600;
  --accent-text: #000000;
  --focus: #00E5FF;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-size: 1.125rem;
  line-height: 1.5;
}

h1, h2 { line-height: 1.2; }

/* "Skip to the game" link: hidden until a keyboard user tabs to it */
.skip-link {
  position: absolute;
  left: 1rem;
  top: -100px;
  z-index: 30;
  padding: 0.75rem 1.25rem;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
  text-decoration: none;
}

.skip-link:focus {
  top: 0.75rem;
  outline: 5px solid var(--focus);
  outline-offset: 3px;
}

a:focus-visible {
  outline: 5px solid var(--focus);
  outline-offset: 3px;
}

/* The skip link moves focus to <main>; no need for a ring around the whole page area. */
main:focus {
  outline: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Buttons: large, high contrast, clear focus ring */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  padding: 0.5rem 1.25rem;
  border: 3px solid var(--accent);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  overflow: hidden;
}

.btn[hidden] {
  display: none;
}

.btn.primary {
  background: var(--accent);
  color: var(--accent-text);
}

.btn.big {
  min-height: 72px;
  padding: 0.75rem 2.5rem;
  font-size: 1.5rem;
}

.btn:focus-visible,
select:focus-visible,
input:focus-visible,
canvas:focus-visible {
  outline: 5px solid var(--focus);
  outline-offset: 3px;
}

.btn:disabled {
  opacity: 0.45;
  cursor: default;
}

/* Hold-to-open: a bar fills along the bottom while the button is held */
.hold-btn {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.hold-btn::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  height: 6px;
  width: calc(var(--hold, 0) * 100%);
  background: var(--accent);
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 2px solid var(--panel-border);
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 2.25rem);
}

.topbar-actions {
  display: flex;
  gap: 0.75rem;
}

.status {
  margin: 0.25rem 0 0;
  min-height: 1.5em;
  font-size: clamp(1.25rem, 3vw, 1.6rem);
  font-weight: 700;
  text-align: center;
}

.note {
  padding: 0.75rem 1rem 1rem;
  color: var(--muted);
  font-size: 0.95rem;
  text-align: center;
}

.note p {
  margin: 0.25rem auto;
  max-width: 48rem;
}

.note a {
  color: var(--accent);
  font-weight: 700;
}

/* Messages shown over the page (finish, break) */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.55);
  z-index: 10;
}

.overlay[hidden] {
  display: none;
}

.overlay-card {
  max-width: 32rem;
  width: 100%;
  padding: 2rem 1.5rem;
  border: 3px solid var(--panel-border);
  border-radius: 22px;
  background: var(--panel);
  text-align: center;
}

.overlay-card h2 {
  margin: 0.5rem 0;
  font-size: clamp(1.6rem, 5vw, 2.2rem);
}

.overlay-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.25rem;
}

/* Caregiver settings */
.settings {
  width: min(38rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  padding: 1.5rem;
  border: 3px solid var(--panel-border);
  border-radius: 20px;
  background: var(--panel);
  color: var(--text);
}

.settings::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.settings h2 {
  margin: 0;
}

.settings fieldset {
  margin: 1rem 0;
  padding: 0.75rem 1rem 1rem;
  border: 2px solid var(--panel-border);
  border-radius: 14px;
}

.settings legend {
  padding: 0 0.4rem;
  font-weight: 700;
}

.settings label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0.75rem 0;
}

.settings label.check {
  flex-direction: row;
  align-items: center;
  gap: 0.75rem;
}

.settings select {
  min-height: 48px;
  padding: 0.25rem 0.5rem;
  border: 2px solid var(--panel-border);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
}

.settings input[type="checkbox"],
.settings input[type="radio"] {
  flex: none;
  width: 1.5rem;
  height: 1.5rem;
  accent-color: var(--accent);
}

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.presets .btn {
  min-height: 48px;
  font-size: 1rem;
}

.hint {
  margin: 0.25rem 0;
  color: var(--muted);
  font-size: 0.95rem;
}

/* Activity choice on the start screen: the chosen one is filled in */
.activity-picker {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
}

.activity-btn[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-text);
}

.activity-btn[aria-pressed="true"]::before {
  content: "\2713\00a0";
}

/* Session history table */
.history-scroll {
  overflow-x: auto;
  margin: 0.5rem 0 0.75rem;
}

.history {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.history th,
.history td {
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--panel-border);
  text-align: left;
  white-space: nowrap;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Reduce motion: no transitions or animations in the page itself */
:root[data-reduce-motion] *,
:root[data-reduce-motion] *::before,
:root[data-reduce-motion] *::after {
  transition: none !important;
  animation: none !important;
}

@media (max-width: 560px) {
  .topbar { justify-content: center; }
  .topbar h1 { width: 100%; text-align: center; order: -1; }
}
