/* =========================================================================
   Mi Voz — Tablero de Comunicación (Aphasia AAC board)
   Designed for an 82-year-old with aphasia + right-side paralysis:
   - HUGE tap targets, large type, high contrast
   - Color-coded categories (AAC convention)
   - Calm, uncluttered; one idea per screen
   ========================================================================= */

:root {
  --bg: #f5f2ec;
  --ink: #1f2933;
  --muted: #6b7280;
  --bar: #ffffff;
  --bar-border: #e5e0d5;

  /* Category colors (Fitzgerald-key inspired) */
  --c-help: #e5484d;      /* emergency / help */
  --c-needs: #2f80ed;     /* needs / verbs */
  --c-feel: #f5a623;      /* feelings */
  --c-yesno: #27ae60;     /* yes / go */
  --c-pain: #8e44ad;      /* pain / body */
  --c-food: #e67e22;      /* food / drink */
  --c-family: #5b48c4;    /* people / family */

  --shadow: 0 2px 6px rgba(0,0,0,0.10);
  --shadow-press: 0 1px 2px rgba(0,0,0,0.18);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ---- Top bar ---- */
.topbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg);
}
.title {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  min-width: 0;
}
.title-name {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.nav-btn {
  width: 3rem;
  height: 3rem;
  font-size: 1.7rem;
  line-height: 1;
  border: none;
  border-radius: 0.9rem;
  background: #ffffff;
  color: var(--ink);
  box-shadow: var(--shadow);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.nav-btn:active { box-shadow: var(--shadow-press); transform: translateY(1px); }

/* ---- Message bar ---- */
.message-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0.75rem 0.75rem;
  padding: 0.6rem 0.75rem;
  background: var(--bar);
  border: 2px solid var(--bar-border);
  border-radius: 1rem;
  box-shadow: var(--shadow);
  min-height: 4rem;
}
.message-text {
  flex: 1;
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1.25;
  word-break: break-word;
}
.message-text.empty { color: var(--muted); font-weight: 500; }
.message-replay, .message-clear {
  width: 3.2rem;
  height: 3.2rem;
  flex: 0 0 auto;
  border: none;
  border-radius: 0.9rem;
  font-size: 1.6rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.message-replay { background: #e8f4ff; color: #1c64c8; }
.message-clear  { background: #fbeaea; color: #c0392b; }
.message-replay:active, .message-clear:active { transform: translateY(1px); }

/* ---- Content grid ---- */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 0 0.75rem 1rem;
  -webkit-overflow-scrolling: touch;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}
@media (min-width: 600px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 900px) {
  .grid { grid-template-columns: repeat(4, 1fr); }
}
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-1 { grid-template-columns: 1fr; }

/* ---- Buttons ---- */
.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 8.5rem;
  padding: 0.75rem 0.5rem;
  border: none;
  border-radius: 1.25rem;
  color: #fff;
  box-shadow: var(--shadow);
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.05s ease, box-shadow 0.05s ease;
  text-align: center;
}
.tile:active { transform: scale(0.97); box-shadow: var(--shadow-press); }

.tile .emoji { font-size: 3.4rem; line-height: 1; }
.tile .label { font-size: 1.35rem; font-weight: 700; line-height: 1.2; }

/* Bigger primary buttons (Sí / No) */
.tile.big { min-height: 10rem; }
.tile.big .emoji { font-size: 4.4rem; }
.tile.big .label { font-size: 1.8rem; }

/* Light-tinted tiles (family, pain body parts) need dark text */
.tile.light { color: var(--ink); }
.tile.light .label { font-weight: 700; }

/* ---- Section heading ---- */
.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0.75rem 0 0.5rem;
  padding: 0 0.25rem;
}
.section-sub {
  font-size: 1.05rem;
  color: var(--muted);
  margin: 0 0 0.75rem;
  padding: 0 0.25rem;
}

/* ---- Pain scale ---- */
.pain-scale {
  display: grid;
  grid-template-columns: repeat(11, 1fr);
  gap: 0.3rem;
  margin-bottom: 1rem;
}
.pain-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.5rem 0.1rem;
  border: none;
  border-radius: 0.8rem;
  background: #fff;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.pain-cell .face { font-size: 1.9rem; line-height: 1; }
.pain-cell .num { font-size: 1rem; font-weight: 700; color: var(--ink); }
.pain-cell.hot { background: #fde2e2; box-shadow: 0 0 0 3px var(--c-help); }
.pain-cell:active { transform: scale(0.94); }

/* ---- Body parts grid ---- */
.body-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
}
@media (min-width: 600px) { .body-grid { grid-template-columns: repeat(3, 1fr); } }

/* ---- Footer help text ---- */
.foot-note {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 1rem;
  color: #4a5568;
}
