/* Tip Calculator — styles matching Figma uZondvg2txWvvHoA2hw4V2, frames 3:5 / 7:2 (v1).
   Constraint overlay (ux-spec.md): every button >= 44x44 px, text >= WCAG AA. */

:root {
  --page-bg: #eef1f0;
  --card-bg: #ffffff;
  --ink: #1f2937;          /* primary text   */
  --ink-muted: #5f6672;    /* secondary text — 5.8:1 on white, 5.3:1 on --field-bg, 5.0:1 on --accent-soft */
  --field-bg: #f3f4f6;
  --field-border: #d1d5db;
  --key-border: #e0e2e6;
  --accent: #146b43;       /* selected / total — 6.5:1 on white, 5.6:1 on --accent-soft */
  --accent-dark: #0f5334;
  --accent-soft: #e6f2ea;
  --radius-card: 24px;
  --radius-field: 12px;
  --radius-btn: 10px;
  --tap: 44px;             /* minimum touch target */
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--page-bg);
  color: var(--ink);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---------------------------------------------------------------- card */

.card {
  width: 480px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 40px;
  background: var(--card-bg);
  border-radius: var(--radius-card);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.header { display: flex; flex-direction: column; gap: 4px; }

.title {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  color: var(--ink);
}

.subtitle {
  margin: 0;
  font-size: 15px;
  font-weight: 400;
  color: var(--ink-muted);
}

.section-label {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--ink-muted);
}

/* ---------------------------------------------------------- bill amount */

.bill-section { display: flex; flex-direction: column; gap: 8px; }

.bill-display {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 16px 20px;
  background: var(--field-bg);
  border: 1px solid var(--field-border);
  border-radius: var(--radius-field);
}

.bill-display:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(20, 107, 67, 0.18);
}

.bill-currency {
  font-size: 32px;
  font-weight: 600;
  color: var(--ink-muted);
}

.bill-value {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 32px;
  font-weight: 700;
  color: var(--ink);
}

.bill-value::placeholder { color: var(--ink-muted); opacity: 1; }

/* -------------------------------------------------------------- keypad */

.keypad { display: flex; flex-direction: column; gap: 10px; }

.key-row { display: flex; gap: 10px; }

.key {
  flex: 1 1 0;
  min-width: var(--tap);
  min-height: 56px;
  padding: 0;
  background: var(--field-bg);
  border: 1px solid var(--key-border);
  border-radius: var(--radius-field);
  font-family: inherit;
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  text-align: center;
  cursor: pointer;
}

.key:hover { background: #e9ebef; }
.key:active { background: #dfe2e7; }
.key:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* --------------------------------------------------------- tip options */

.tip-section { display: flex; flex-direction: column; gap: 10px; }

.tip-options { display: flex; gap: 8px; }

.tip-btn {
  flex: 1 1 0;
  min-width: var(--tap);
  min-height: var(--tap);
  padding: 12px 4px;
  background: var(--card-bg);
  border: 1px solid var(--field-border);
  border-radius: var(--radius-btn);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  text-align: center;
  cursor: pointer;
}

.tip-btn:hover { background: var(--field-bg); }
.tip-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.tip-btn.is-selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.tip-btn.is-selected:hover { background: var(--accent-dark); border-color: var(--accent-dark); }

/* ----------------------------------------------------------- custom tip */

.custom-tip-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--field-bg);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-btn);
}

.custom-tip-row.is-hidden { display: none; }

.custom-tip-label {
  flex: 1 1 auto;
  font-size: 15px;
  font-weight: 400;
  color: var(--ink-muted);
}

.custom-tip-value { display: flex; align-items: baseline; gap: 2px; }

.custom-tip-input {
  width: 84px;
  padding: 4px 0;
  border: 0;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  text-align: right;
}

.custom-tip-suffix { font-size: 18px; font-weight: 600; color: var(--ink-muted); }

/* ------------------------------------------------------------- results */

.results {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px;
  background: var(--accent-soft);
  border-radius: 14px;
}

.result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.result-label { font-size: 15px; font-weight: 400; color: var(--ink-muted); }

.result-label--total { font-size: 17px; font-weight: 600; color: var(--ink); }

.result-value { font-size: 17px; font-weight: 600; color: var(--ink); }

.result-total { font-size: 22px; font-weight: 700; color: var(--accent); }

/* ----------------------------------------------------------- responsive */

@media (max-width: 520px) {
  body { padding: 0; align-items: flex-start; }
  .card { width: 100%; padding: 24px; gap: 20px; border-radius: 0; }
  .bill-currency, .bill-value { font-size: 28px; }
  .tip-btn { font-size: 14px; }
}
