/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: #222;
  background: #f5f5f5;
  margin: 0;
  padding: 0 0 2rem;
}

/* ── Header ───────────────────────────────────────────────── */
header {
  background: #1a1a2e;
  color: #fff;
  padding: 0.75rem 1.5rem;
  margin-bottom: 1.5rem;
}

.site-title {
  color: #fff;
  text-decoration: none;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.site-title:hover { text-decoration: underline; }

/* ── Layout ───────────────────────────────────────────────── */
main {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1rem;
}

h2 { margin-top: 0; }

/* ── Entry form ───────────────────────────────────────────── */
.entry-form {
  max-width: 420px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 1.5rem;
  margin: 1rem auto;
}

.entry-form label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.entry-form input[type="text"] {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 1.1rem;
  border: 1px solid #bbb;
  border-radius: 4px;
  margin-bottom: 0.75rem;
}

.entry-form button {
  width: 100%;
  padding: 0.55rem;
  font-size: 1rem;
  background: #1a1a2e;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.entry-form button:hover { background: #2e2e50; }

.entry-form .meta { margin-top: 0.5rem; }

/* ── Schedule header ──────────────────────────────────────── */
.schedule-header {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}

.source-link {
  font-size: 0.85rem;
  color: #555;
}

.meta {
  font-size: 0.82rem;
  color: #666;
  margin-top: -0.5rem;
}

/* ── Session details ──────────────────────────────────────── */
details {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  margin-bottom: 1rem;
  overflow: hidden;
}

details summary {
  cursor: pointer;
  background: #e8eaf0;
  padding: 0.6rem 1rem;
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

details summary::-webkit-details-marker { display: none; }
details[open] summary { border-bottom: 1px solid #ccc; }

.session-label { flex: 1; }

/* ── Status badges ────────────────────────────────────────── */
.badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  white-space: nowrap;
}

.badge.delay  { background: #fde8e8; color: #900; }
.badge.ahead  { background: #e2f4e2; color: #060; }

/* ── Table ────────────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 0.4rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid #eee;
}

th {
  background: #f7f7f7;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #555;
}

td.time     { font-variant-numeric: tabular-nums; font-weight: 600; }
td.duration { color: #666; font-size: 0.88rem; }
td.duration .duration-label { font-size: 0.75rem; color: #999; margin-left: 2px; }
td.status-label { font-size: 0.88rem; }

/* ── Row states ───────────────────────────────────────────── */
tr.status-completed {
  opacity: 0.45;
}

tr.status-completed:not(.special) {
  text-decoration: line-through;
  text-decoration-color: #aaa;
}

tr.status-upcoming {
  background: #eaf5ea;
}

tr.status-upcoming td { font-weight: 500; }

tr.status-not_ready { color: #888; }

tr.active {
  background: #fff3cd;
  border-left: 3px solid #f0a500;
}

tr.active td { font-weight: 600; }

/* ── Event action buttons ─────────────────────────────────── */
.evt-btn {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.78rem;
  font-weight: 500;
  border-radius: 4px;
  text-decoration: none;
  margin-right: 4px;
  white-space: nowrap;
}

.evt-btn-live { background: #f8d7da; color: #842029; border: 1px solid #f1aeb5; font-weight: 700; }
.evt-btn-live:hover { background: #f1aeb5; }
.evt-btn-r  { background: #d4edda; color: #155724; border: 1px solid #b8ddc8; }
.evt-btn-r:hover  { background: #b8ddc8; }
.evt-btn-sl { background: #cce5ff; color: #004085; border: 1px solid #b8d4f0; }
.evt-btn-sl:hover { background: #b8d4f0; }
.evt-btn-a  { background: #fff3cd; color: #856404; border: 1px solid #e8d99a; }
.evt-btn-a:hover  { background: #e8d99a; }

/* ── HTMX indicator ───────────────────────────────────────── */
.htmx-indicator {
  display: none;
  font-size: 0.8rem;
  color: #777;
  margin-top: 0.5rem;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  display: inline;
}

/* ── Meta bar (schedule page) ─────────────────────────────── */
.meta-toggle-form { display: inline; margin: 0; padding: 0; }

/* ── Misc ─────────────────────────────────────────────────── */
.no-data {
  padding: 1rem;
  color: #666;
  font-style: italic;
}

a { color: #1a1a2e; }

/* ── Mobile: card layout (≤ 600px) ───────────────────────── */
@media (max-width: 600px) {
  body { font-size: 16px; }

  /* Session summary — larger tap target */
  details summary { padding: 0.85rem 1rem; }

  /* Badges */
  .badge { font-size: 0.8rem; }

  /* ── Table → card transformation ── */
  details { overflow: visible; }
  table   { display: block; }
  thead   { display: none; }
  tbody   { display: block; background: #e8eaf0; padding: 0.35rem 0 0.4rem; }

  tr {
    display: flex;
    flex-wrap: wrap;
    background: #fff;
    border-radius: 7px;
    margin: 0.3rem 0.5rem;
    border: 1px solid #e0e0e0;
    overflow: hidden;
  }

  td {
    display: block;
    border-bottom: none;
    padding: 0;
  }

  /* Event name — full width, primary */
  td:nth-child(1) {
    order: 1;
    flex: 0 0 100%;
    font-size: 1rem;
    font-weight: 700;
    color: #1a1a1a;
    padding: 0.6rem 0.8rem 0.2rem;
    line-height: 1.3;
  }

  /* Predicted time — secondary, inline */
  td.time {
    order: 2;
    font-size: 0.82rem;
    font-weight: 700;
    color: #1a1a2e;
    padding: 0 0 0.35rem 0.8rem;
  }

  /* Duration — secondary, after time */
  td.duration {
    order: 2;
    font-size: 0.78rem;
    color: #777;
    padding: 0 0.8rem 0.35rem 0.4rem;
  }

  td.duration::before {
    content: "·";
    margin-right: 4px;
    color: #bbb;
  }

  td.duration .duration-label {
    font-size: 0.73rem;
    color: #999;
    margin-left: 3px;
  }

  /* Status/actions — full width, bottom */
  td.status-label {
    order: 3;
    flex: 0 0 100%;
    padding: 0.2rem 0.7rem 0.45rem;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 0; /* hide lone dash without hiding buttons */
  }

  /* ── Row states as card variants ── */

  /* Completed: remove global tr strikethrough; apply only to name cell */
  tr.status-completed {
    opacity: 0.52;
    text-decoration: none;
  }

  tr.status-completed:not(.special) {
    text-decoration: none; /* override global */
  }

  tr.status-completed:not(.special) td:nth-child(1) {
    text-decoration: line-through;
    text-decoration-color: #bbb;
    color: #666;
    font-weight: 500;
  }

  /* Special completed — no strikethrough */
  tr.status-completed.special td:nth-child(1) {
    text-decoration: none;
    color: #888;
    font-weight: 400;
  }

  /* Upcoming — green left accent */
  tr.status-upcoming {
    border-left: 4px solid #2d8a2d;
    background: #f6fbf6;
  }

  tr.status-upcoming td { font-weight: inherit; }

  /* Not ready — subdued name */
  tr.status-not_ready td:nth-child(1) {
    color: #aaa;
    font-weight: 400;
  }

  /* Active — amber left accent (override global 3px) */
  tr.active {
    border-left: 4px solid #f0a500;
  }

  /* ── Action buttons ── */
  .evt-btn {
    display: inline-flex;
    align-items: center;
    height: 34px;
    padding: 0 12px;
    font-size: 0.8rem;
    font-weight: 600;
  }

  tr.status-completed .evt-btn {
    height: 28px;
    font-size: 0.73rem;
    padding: 0 10px;
  }

  /* ── Defaults table — opt out of card transform ── */
  table.defaults-table,
  table.defaults-table thead,
  table.defaults-table tbody,
  table.defaults-table tr,
  table.defaults-table td { display: revert; }

  table.defaults-table tbody { background: transparent; padding: 0; }

  table.defaults-table td {
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid #eee;
  }

  table.defaults-table td:nth-child(1) {
    font-size: inherit;
    font-weight: inherit;
    color: inherit;
    padding: 0.4rem 0.6rem;
    line-height: inherit;
  }

  /* ── Meta bar — toggle pill ── */
  .meta.meta-bar {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.45rem;
    margin-top: 0;
  }

  .meta-toggle-form { display: block; }

  label.meta-toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 36px;
    padding: 4px 12px;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #3730a3;
    cursor: pointer;
  }

  label.meta-toggle-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #1a1a2e;
    cursor: pointer;
  }
}
