/* Family Board v2 — iPad player styles (public/play/play.css)
   MadeForMyKids look: coral #ff7d26, slate #1e293b, cream #fffbf7,
   Fredoka headings + Inter body. Landscape-first, big tap targets (min 56px). */

:root {
  --coral: #ff7d26;
  --coral-dark: #e56a12;
  --slate: #1e293b;
  --slate-soft: #475569;
  --cream: #fffbf7;
  --card: #ffffff;
  --line: #f1e4d6;
  --danger: #dc2626;
  --radius: 18px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--cream);
  color: var(--slate);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 17px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, .brand, .clock, .cal-title, .sheet-title {
  font-family: 'Fredoka', 'Inter', -apple-system, sans-serif;
  color: var(--slate);
}

button { font-family: inherit; cursor: pointer; }
button:disabled { opacity: 0.55; cursor: default; }

.screen { min-height: 100vh; min-height: 100dvh; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  padding: 12px 28px;
  border: none;
  border-radius: 14px;
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
}
.btn-primary { background: var(--coral); color: #fff; }
.btn-primary:hover { background: var(--coral-dark); }
.btn-secondary { background: #f1e4d6; color: var(--slate); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-big { width: 100%; font-size: 20px; }

.icon-btn {
  min-width: 56px;
  min-height: 56px;
  border: none;
  border-radius: 12px;
  background: #f1e4d6;
  color: var(--slate);
  font-size: 30px;
  line-height: 1;
}

.error {
  color: var(--danger);
  font-weight: 600;
  margin: 12px 0;
}

.empty-note { color: var(--slate-soft); text-align: center; padding: 16px; }

/* ---------- unpaired / pairing screen ---------- */
#screen-unpaired {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.pair-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 8px 30px rgba(30, 41, 59, 0.08);
  max-width: 560px;
  width: 100%;
  padding: 40px 36px;
  text-align: center;
}
.pair-logo { font-size: 56px; line-height: 1; }
.pair-card h1 { font-size: 40px; margin: 12px 0 4px; }
.pair-sub { font-size: 22px; font-weight: 700; color: var(--coral); margin: 4px 0 12px; }
.pair-help { color: var(--slate-soft); margin: 0 0 24px; }
.pair-card label {
  display: block;
  text-align: left;
  font-weight: 700;
  margin-bottom: 8px;
}
#pair-code {
  width: 100%;
  min-height: 64px;
  padding: 12px 16px;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 0.35em;
  text-align: center;
  text-transform: uppercase;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--cream);
  color: var(--slate);
}
#pair-code:focus { outline: 3px solid var(--coral); border-color: var(--coral); }
#pair-form .btn { margin-top: 20px; }
.pair-note { color: var(--slate-soft); font-size: 14px; margin: 20px 0 0; }

/* ---------- dashboard layout ---------- */
.dashboard { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }

.dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.brand { font-size: 28px; font-weight: 700; }
.family-name { color: var(--slate-soft); font-size: 16px; }
.header-right { text-align: right; }
.header-date { font-size: 16px; color: var(--slate-soft); }
.clock { font-size: 34px; font-weight: 700; line-height: 1.1; }

.dash-body {
  flex: 1;
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr) 96px;
  gap: 16px;
  padding: 16px;
  align-items: start;
}

.left-col { display: flex; flex-direction: column; gap: 16px; }
.main-col { min-width: 0; }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.panel h2 { margin: 0 0 12px; font-size: 22px; }

/* ---------- month calendar ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cal-title { margin: 0; font-size: 20px; flex: 1; text-align: center; }
.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--slate-soft);
  margin-top: 12px;
}
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 4px; }
.cal-day {
  position: relative;
  min-height: 44px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--slate);
  font-size: 16px;
  font-weight: 600;
}
.cal-day:hover { background: #fdf0e3; }
.cal-day-blank { visibility: hidden; }
.cal-day.is-today { outline: 2px solid var(--coral); outline-offset: -2px; }
.cal-day.is-selected { background: var(--coral); color: #fff; }
.cal-dot {
  position: absolute;
  left: 50%;
  bottom: 4px;
  transform: translateX(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--coral);
}
.cal-day.is-selected .cal-dot { background: #fff; }
#today-btn { width: 100%; margin-top: 12px; }

/* ---------- stars panel ---------- */
.stars-panel h2 { font-size: 20px; }
.star-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  padding: 8px 4px;
  border-top: 1px solid var(--line);
}
.star-row:first-of-type { border-top: none; }
.star-name { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.star-count { font-weight: 700; color: var(--coral); white-space: nowrap; }
.star-progress { color: var(--slate-soft); font-size: 14px; white-space: nowrap; }
.stars-note { color: var(--slate-soft); font-size: 14px; margin: 8px 0 0; }

.kid-dot {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex: none;
}
.kid-emoji { font-size: 20px; }

/* ---------- timeline ---------- */
.timeline-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.timeline-head h2 { margin: 0; }
.timeline-summary { color: var(--slate-soft); font-weight: 600; }

.timeline-scroll { overflow-x: auto; overflow-y: auto; max-height: calc(100vh - 260px); max-height: calc(100dvh - 260px); }

.allday-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 8px;
  padding: 8px 0;
  border-bottom: 2px solid var(--line);
  align-items: stretch;
}
.axis-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--slate-soft);
  display: flex;
  align-items: center;
}
.allday-cols { display: grid; gap: 8px; min-width: 0; }
.allday-cell { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.allday-empty { color: var(--slate-soft); font-size: 14px; }

.kid-column-headers {
  display: grid;
  gap: 8px;
  margin-left: 80px; /* aligns with kid columns: 72px axis + 8px gap */
  padding: 10px 0 6px;
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 3;
}
.kid-column-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 700;
  min-height: 44px;
  background: var(--cream);
  border-radius: 10px;
  padding: 4px 8px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.kid-name { overflow: hidden; text-overflow: ellipsis; }

.timeline-body {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 8px;
  position: relative;
}
.time-axis { position: relative; }
.time-label {
  position: absolute;
  right: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--slate-soft);
  white-space: nowrap;
}
.kid-columns { display: grid; gap: 8px; min-width: 0; }
.kid-column {
  position: relative;
  min-width: 0;
  border-radius: 12px;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 63px,
    var(--line) 63px,
    var(--line) 64px
  );
  background-color: #fffdf9;
  border: 1px solid var(--line);
}

.task-block {
  position: absolute;
  left: 4px;
  width: calc(100% - 8px);
  min-height: 56px;
  border: none;
  border-radius: 12px;
  color: #fff;
  text-align: left;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(30, 41, 59, 0.18);
  /* Double-tap opens the task: stop iOS Safari zooming on the second tap.
     Pinch zoom still works; this only disables double-tap-to-zoom. */
  touch-action: manipulation;
}
.task-block.is-allday { position: static; width: 100%; min-height: 56px; }
.task-block-title { font-weight: 700; font-size: 15px; line-height: 1.25; overflow: hidden; }
.task-block-meta { font-size: 13px; opacity: 0.92; }
.task-block-check {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 18px;
  font-weight: 700;
}
.task-block.is-complete { opacity: 0.55; }
.task-block.is-complete .task-block-title { text-decoration: line-through; }

/* ---------- tasks list view ---------- */
.tasks-list { display: flex; flex-direction: column; gap: 20px; }
.tasks-kid-group h3 { margin: 0 0 8px; font-size: 19px; display: flex; align-items: center; gap: 8px; }
.task-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 64px;
  padding: 10px 14px;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--cream);
  text-align: left;
  font-size: 17px;
  color: var(--slate);
}
.task-row-check { font-size: 22px; color: var(--coral); flex: none; }
.task-row-title { font-weight: 700; flex: 1; min-width: 0; }
.task-row-meta { color: var(--slate-soft); font-size: 15px; white-space: nowrap; }
.task-row.is-complete { opacity: 0.6; }
.task-row.is-complete .task-row-title { text-decoration: line-through; }

/* ---------- coming soon / settings ---------- */
.coming-soon { text-align: center; padding: 64px 24px; }
.coming-emoji { font-size: 64px; line-height: 1; }
.coming-soon h2 { font-size: 28px; margin: 16px 0 8px; }
.coming-soon p { color: var(--slate-soft); max-width: 420px; margin: 0 auto; }

.settings-list { margin: 0 0 16px; }
.settings-list > div {
  display: flex;
  gap: 16px;
  min-height: 56px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding: 8px 0;
}
.settings-list > div:first-child { border-top: none; }
.settings-list dt { font-weight: 700; width: 150px; flex: none; }
.settings-list dd { margin: 0; }
.settings-note { color: var(--slate-soft); }

/* ---------- right icon rail ---------- */
.rail {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 8px;
  position: sticky;
  top: 16px;
}
.rail-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 72px;
  min-height: 72px;
  border: none;
  border-radius: 14px;
  background: transparent;
  color: var(--slate-soft);
}
.rail-btn:hover { background: #fdf0e3; }
.rail-btn.is-active { background: var(--coral); color: #fff; }
.rail-icon { font-size: 28px; line-height: 1; }
.rail-label { font-size: 12px; font-weight: 700; }

/* ---------- detail sheet ---------- */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(30, 41, 59, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}
.sheet {
  position: relative;
  background: var(--card);
  border-radius: 24px 24px 0 0;
  width: 100%;
  max-width: 640px;
  padding: 32px 28px calc(28px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 40px rgba(30, 41, 59, 0.25);
}
.sheet-close {
  position: absolute;
  top: 12px;
  right: 12px;
  min-width: 56px;
  min-height: 56px;
  border: none;
  border-radius: 50%;
  background: #f1e4d6;
  color: var(--slate);
  font-size: 22px;
}
.sheet-kid { font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.sheet-title { font-size: 30px; margin: 10px 0 6px; }
.sheet-time { color: var(--slate-soft); font-size: 18px; margin: 0 0 6px; }
.sheet-stars { color: var(--coral); font-size: 20px; font-weight: 700; margin: 0 0 24px; }

/* ---------- narrower / portrait fallback ---------- */
@media (max-width: 900px) {
  .dash-body { grid-template-columns: 300px minmax(0, 1fr); }
  .rail {
    grid-column: 1 / -1;
    flex-direction: row;
    justify-content: space-around;
    position: static;
    padding: 8px;
  }
  .rail-btn { flex: 1; min-height: 64px; }
}
@media (max-width: 640px) {
  .dash-body { grid-template-columns: minmax(0, 1fr); }
  .clock { font-size: 26px; }
  .brand { font-size: 22px; }
  .timeline-scroll { max-height: none; }
}
