/* Meetings — bright, tactile, one-handed. */

:root {
  --bg: #fff7ec;
  --ink: #2b2338;
  --paper: #ffffff;
  --line: #efe3d0;
  --accent: #ff5d73;
  --meeting: #ff9770;
  --focus: #b388eb;
  --errand: #ffd166;
  --personal: #6fd8b2;
  --good: #2fbf71;
  --bad: #e5484d;
  --cell-h: 52px;
  --gap: 5px;
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--ink);
  max-width: 480px;
  margin: 0 auto;
  padding: 10px 10px calc(16px + env(safe-area-inset-bottom));
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 2px 10px;
}

h1 {
  font-size: 1.5rem;
  letter-spacing: -0.02em;
}

h1 span {
  font-size: 0.9rem;
  color: var(--accent);
  font-weight: 700;
  vertical-align: super;
}

.header-right { display: flex; gap: 10px; align-items: center; }

#streak { font-weight: 700; font-size: 1rem; }

#help-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: var(--paper);
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
}

/* ---- Board ---- */

#board {
  display: grid;
  grid-template-columns: 36px repeat(7, 1fr);
  gap: var(--gap);
}

.day-head {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 800;
  color: #8a7d6d;
  padding-bottom: 2px;
}

.day-head.weekend { color: var(--accent); }

.time-label {
  font-size: 0.62rem;
  color: #a5988a;
  text-align: right;
  padding-right: 3px;
  align-self: center;
  font-variant-numeric: tabular-nums;
}

.cell {
  position: relative;
  height: var(--cell-h);
  background: var(--paper);
  border: 1.5px dashed var(--line);
  border-radius: 8px;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.cell.weekend { background: #fffdf6; }

.cell.valid {
  border: 2px solid var(--accent);
  background: #fff0f2;
  cursor: pointer;
  animation: glow 1.2s ease-in-out infinite;
}

.cell.cont { border-style: solid; border-color: transparent; background: transparent; }

.cell.armed {
  border: 2px solid var(--focus);
  background: #f4edff;
  animation: glow 1.2s ease-in-out infinite;
  cursor: pointer;
}

.cell.valid.hover {
  border-style: solid;
  background: #ffdfe5;
  transform: scale(1.08);
}

@keyframes glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 93, 115, 0); }
  50% { box-shadow: 0 0 0 4px rgba(255, 93, 115, 0.35); }
}

/* ---- Chips ---- */

.chip {
  border: none;
  border-radius: 8px;
  font-family: inherit;
  color: var(--ink);
  cursor: grab;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  overflow: hidden;
  touch-action: none; /* pointer-drag on touch instead of scrolling */
}

.drag-ghost {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
  pointer-events: none;
  opacity: 0.95;
  box-shadow: 0 10px 28px rgba(43, 35, 56, 0.35);
}

.drag-source { opacity: 0.35; }

.type-meeting { background: var(--meeting); }
.type-focus { background: var(--focus); }
.type-errand { background: var(--errand); }
.type-personal { background: var(--personal); }

.chip.placed {
  position: absolute;
  inset: 2px;
  z-index: 2;
  animation: plop 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 2px 0 rgba(43, 35, 56, 0.18);
}

.chip.placed.tall { height: calc(var(--cell-h) * 2 + var(--gap) - 4px); }

.chip.placed .chip-icon { font-size: 1.05rem; line-height: 1; }

.chip.placed .chip-name {
  font-size: 0.5rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.05;
  max-width: 100%;
}

.chip.placed.good { outline: 2px solid var(--good); outline-offset: -2px; }
.chip.placed.bad { outline: 2px solid var(--bad); outline-offset: -2px; }

.chip.placed.inspected {
  outline: 3px solid var(--ink);
  outline-offset: -1px;
  z-index: 3;
  transform: scale(1.06);
}

@keyframes plop {
  0% { transform: scale(0.6, 1.3); }
  60% { transform: scale(1.15, 0.85); }
  100% { transform: scale(1, 1); }
}

/* ---- Tray ---- */

#hint {
  min-height: 3.4em;
  font-size: 0.8rem;
  color: #6d6152;
  padding: 6px 4px 2px;
  line-height: 1.35;
}

#hint span { display: block; }

.hint-title { font-weight: 800; color: var(--ink); font-size: 0.85rem; }

.hint-meta { font-size: 0.72rem; color: #a5988a; }

.hint-live { color: var(--ink); font-weight: 600; margin-top: 2px; }

.hint-tap { font-size: 0.72rem; color: #a5988a; font-style: italic; }

#tray {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 6px 0 12px;
  min-height: 56px;
}

.tray-card {
  flex-direction: row;
  gap: 6px;
  padding: 9px 11px;
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-weight: 700;
  box-shadow: 0 3px 0 rgba(43, 35, 56, 0.18);
  transition: transform 0.1s, box-shadow 0.1s;
}

.tray-card:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(43, 35, 56, 0.18); }

.tray-card.selected {
  outline: 3px solid var(--ink);
  transform: scale(1.05);
}

.tray-card.dim { opacity: 0.35; }

.chip-badges { font-size: 0.72rem; letter-spacing: -1px; }

.tray-empty {
  font-size: 0.85rem;
  color: #8a7d6d;
  padding: 10px 4px;
  font-style: italic;
}

/* ---- Submit ---- */

#submit {
  width: 100%;
  padding: 15px;
  border: none;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 0 #d13a52;
  transition: transform 0.1s, box-shadow 0.1s, opacity 0.2s;
}

#submit:disabled {
  background: #d8cebd;
  box-shadow: 0 4px 0 #c2b6a2;
  cursor: default;
}

#submit:not(:disabled):active { transform: translateY(3px); box-shadow: 0 1px 0 #d13a52; }

/* ---- Overlay / debrief ---- */

#overlay, #help {
  position: fixed;
  inset: 0;
  background: rgba(43, 35, 56, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 10;
}

#overlay[hidden], #help[hidden] { display: none; }

.card {
  background: var(--paper);
  border-radius: 18px;
  padding: 20px;
  width: 100%;
  max-width: 420px;
  max-height: 88vh;
  overflow-y: auto;
  animation: rise 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}

@keyframes rise {
  from { transform: translateY(24px) scale(0.96); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.card h2 { font-size: 1.2rem; margin-bottom: 8px; }
.card h3 { font-size: 0.85rem; margin: 14px 0 4px; color: #8a7d6d; text-transform: uppercase; letter-spacing: 0.05em; }

.score-row { display: flex; align-items: baseline; gap: 8px; }

.big-score {
  font-size: 3rem;
  font-weight: 900;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.tier { font-size: 1.05rem; font-weight: 800; margin: 2px 0 2px; }

.next-grade { font-size: 0.8rem; color: #8a7d6d; font-weight: 700; margin-bottom: 8px; }

.day-emojis { font-size: 1.5rem; letter-spacing: 3px; margin-bottom: 6px; }

.best { font-size: 0.8rem; color: #8a7d6d; }

.roasts, .misses, .help-list { list-style: none; }

.roasts li, .misses li, .help-list li {
  font-size: 0.88rem;
  line-height: 1.35;
  padding: 5px 0 5px 2px;
  border-bottom: 1px dashed var(--line);
}

.roasts li::before { content: '🔥 '; }
.roasts li.praise::before { content: '✨ '; }
.misses li::before { content: '💸 '; }
.misses li.par-gap::before { content: '⛳ '; }
.help-list li { border-bottom: none; padding: 4px 0; }

.legend { font-size: 0.75rem; color: #8a7d6d; margin-top: 10px; line-height: 1.5; }

.streak-line { font-weight: 800; margin-top: 10px; }

.btn-row { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

.btn-row button {
  flex: 1;
  min-width: 100px;
  padding: 12px 8px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: var(--paper);
  font-family: inherit;
  font-weight: 800;
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform 0.1s;
}

.btn-row button:active { transform: scale(0.96); }

.btn-row .primary { background: var(--accent); border-color: var(--accent); color: #fff; }

@media (max-width: 360px) {
  :root { --cell-h: 46px; }
  .chip.placed .chip-name { display: none; }
}
