/* pghkids — warm, readable, kid-friendly without being childish. */

:root {
  --bg:        #fbf6ef;       /* warm cream */
  --surface:   #ffffff;
  --surface-2: #fff8ec;
  --ink:       #1f2937;       /* near-black */
  --muted:     #6b7280;
  --line:      #ecdfc9;
  --primary:   #2c8a78;       /* deep teal */
  --primary-2: #1f6e5e;
  --accent:    #ff7849;       /* warm coral */
  --accent-2:  #e85c2c;
  --warning:   #d97706;
  --shadow:    0 1px 3px rgba(31,41,55,.06), 0 4px 12px rgba(31,41,55,.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}

a { color: var(--primary-2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- top bar ---------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand .logo {
  display: inline-grid;
  place-items: center;
  width: 44px; height: 44px;
  background: var(--accent);
  color: white;
  border-radius: 12px;
  font-size: 22px;
  box-shadow: var(--shadow);
}
.brand h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.brand .tagline { margin: 0; font-size: 13px; color: var(--muted); }

.controls {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.controls label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 600;
}
.controls input[type="number"], .controls select {
  font: inherit;
  font-size: 15px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}
.age input[type="number"] { width: 56px; text-align: center; }

.viewtoggle {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
}
.viewtoggle button {
  border: none;
  background: transparent;
  padding: 7px 18px;
  border-radius: 999px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.viewtoggle button.active {
  background: var(--surface);
  color: var(--primary-2);
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}

/* ---------- main ---------- */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px 80px;
}

.status {
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 10px 14px;
  border-radius: 10px;
  margin-bottom: 20px;
  font-size: 14px;
  color: var(--muted);
}

/* ---------- list view ---------- */
.event-list { display: flex; flex-direction: column; gap: 30px; }

.day-group h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-2);
  font-weight: 700;
  margin: 0 0 12px;
  padding-bottom: 6px;
  border-bottom: 2px dashed var(--line);
}
.day-group .day-sub {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  margin-left: 8px;
  letter-spacing: 0;
  text-transform: none;
}

.event-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
  display: grid;
  grid-template-columns: 90px 1fr auto;
  gap: 16px;
  align-items: start;
  margin-bottom: 12px;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.event-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.event-time {
  text-align: center;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 10px 6px;
  font-weight: 600;
}
.event-time .t1 { font-size: 18px; color: var(--ink); display: block; }
.event-time .t2 { font-size: 12px; color: var(--muted); display: block; margin-top: 2px; }
.event-time.allday .t1 { font-size: 13px; color: var(--accent-2); text-transform: uppercase; letter-spacing: .04em; }

.event-main h3 {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 4px;
  line-height: 1.3;
  color: var(--ink);
}
.event-main .meta {
  color: var(--muted);
  font-size: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
}
.event-main .meta span { display: inline-flex; align-items: center; gap: 4px; }
.event-main .desc {
  margin-top: 8px;
  font-size: 14px;
  color: #4b5563;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.age-pill {
  background: #e8f5f1;
  color: var(--primary-2);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  align-self: start;
}
.age-pill.unknown {
  background: #fff3e0;
  color: var(--warning);
}

@media (max-width: 600px) {
  .event-card { grid-template-columns: 70px 1fr; padding: 14px; gap: 12px; }
  .age-pill { grid-column: 2; justify-self: start; }
}

/* ---------- calendar view ---------- */
.cal-view { background: var(--surface); padding: 16px; border-radius: 14px; border: 1px solid var(--line); }
#calendar .fc-event {
  background: var(--primary);
  border-color: var(--primary-2);
  cursor: pointer;
}
#calendar .fc-event.unknown-age { background: var(--accent); border-color: var(--accent-2); }
#calendar .fc-button-primary {
  background: var(--primary);
  border-color: var(--primary);
}
#calendar .fc-button-primary:hover,
#calendar .fc-button-primary:not(:disabled).fc-button-active {
  background: var(--primary-2);
  border-color: var(--primary-2);
}
#calendar .fc-toolbar-title { color: var(--ink); font-weight: 600; }

/* ---------- empty / footer / modal ---------- */
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
button.primary {
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 999px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  margin-top: 12px;
}
button.primary:hover { background: var(--accent-2); }
button.link {
  background: transparent;
  border: none;
  color: var(--primary-2);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

.foot {
  margin-top: 40px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(31,41,55,.45);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 50;
}
/* `display: grid` above overrides the HTML `hidden` attribute, so the modal
   was visible on first load. This re-asserts hidden semantics. */
.modal[hidden] { display: none; }
.modal-inner {
  background: var(--surface);
  border-radius: 16px;
  padding: 26px 28px;
  width: 100%;
  max-width: 540px;
  position: relative;
  box-shadow: 0 10px 40px rgba(0,0,0,.2);
  max-height: 86vh;
  overflow: auto;
}
.modal-inner .close {
  position: absolute;
  top: 10px; right: 14px;
  background: transparent;
  border: none;
  font-size: 24px;
  color: var(--muted);
  cursor: pointer;
}
#modal-body h2 { margin: 0 0 8px; font-size: 22px; line-height: 1.25; }
#modal-body .modal-when, #modal-body .modal-where { color: var(--muted); margin: 4px 0; font-size: 14px; }
#modal-body .modal-desc { margin: 14px 0; font-size: 15px; line-height: 1.55; white-space: pre-wrap; }
#modal-body .modal-source { font-size: 12px; color: var(--muted); margin-top: 8px; }
#modal-body a.go {
  display: inline-block;
  background: var(--primary);
  color: white;
  padding: 9px 18px;
  border-radius: 999px;
  margin-top: 8px;
  font-weight: 600;
  font-size: 14px;
}
#modal-body a.go:hover { background: var(--primary-2); text-decoration: none; }
