/* ===========================================================================
   Barbershop Lopez — booking UI
   Editorial serif (Didot on Apple) + SF Pro. Black, warm gold, hairline rules.
   Colour tokens are overwritten at runtime from config/business.js.
   =========================================================================== */

:root {
  --bg: #000;
  --surface: #0e0e0e;
  --raised: #131313;
  --accent: #c6a664;
  --text: #f5f2ec;
  --muted: #8c8880;
  --border: #242220;

  --hairline: rgba(255, 255, 255, 0.09);
  --gold-veil: rgba(198, 166, 100, 0.09);

  --serif: 'Didot', 'Bodoni 72', 'Playfair Display', 'Times New Roman', serif;
  --sans: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', system-ui, sans-serif;

  /* Replaced with the measured bar height on every render. */
  --bar-h: 96px;
}

* { box-sizing: border-box; }
html, body { background: var(--bg); }

body {
  margin: 0;
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button { font: inherit; color: inherit; }

.wrap {
  max-width: 460px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 26px) 20px calc(var(--bar-h) + 36px);
}

/* First screen only — service cards settle into the middle of the phone. */
.wrap.initial { min-height: 100dvh; display: flex; flex-direction: column; }
.wrap.initial > section { margin-top: auto; margin-bottom: auto; }

.center { text-align: center; }
.muted { color: var(--muted); font-size: 14px; }
.small { font-size: 12px; }
.error { color: #e0685f; font-size: 13px; }

/* ── Header ───────────────────────────────────────────────────────────────── */

.head { text-align: center; margin-bottom: 34px; }

.brand {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 30px;
  line-height: 1.1;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0;
}

.head-rule {
  display: block;
  width: 34px;
  height: 1px;
  margin: 14px auto 12px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

.head-addr {
  margin: 0;
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1.7;
}

/* ── Section headings ─────────────────────────────────────────────────────── */

h2 {
  font-family: var(--sans);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--hairline);
}

section { margin-bottom: 32px; }

/* ── Service cards ────────────────────────────────────────────────────────── */

.services { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }

.service {
  width: 100%;
  display: block;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 17px 18px;
  cursor: pointer;
  transition: border-color 0.22s ease, background-color 0.22s ease;
}
.service.on {
  border-color: var(--accent);
  background: linear-gradient(var(--gold-veil), var(--gold-veil)), var(--surface);
}

.service-row { display: flex; align-items: center; gap: 15px; }

.radio {
  width: 17px; height: 17px; border-radius: 50%;
  border: 1px solid #4a463f; flex: none;
  transition: border-color 0.22s ease, box-shadow 0.22s ease, background-color 0.22s ease;
}
.radio.on {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: inset 0 0 0 3.5px var(--surface);
}

.service-text { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }

.service-name {
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1.15;
  letter-spacing: 0.015em;
}

.service-dur {
  font-size: 11px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--muted);
}

.service-price {
  font-family: var(--serif);
  font-size: 20px;
  color: var(--accent);
  flex: none;
  font-variant-numeric: tabular-nums;
}

/* Description: present in the DOM, revealed only for the selected card. */
.service-desc {
  display: block;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.24s ease, margin-top 0.3s ease;
}
.service-desc.on { max-height: 140px; opacity: 1; margin-top: 13px; }

.service-desc-inner {
  display: block;
  padding-top: 13px;
  border-top: 1px solid var(--hairline);
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
  padding-left: 32px; /* aligns under the service name, clear of the radio */
}

/* ── Date strip ───────────────────────────────────────────────────────────── */

.month {
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.2em;
  color: var(--muted);
  margin: 0 0 12px;
}

.dates {
  display: flex; gap: 9px; overflow-x: auto;
  padding-bottom: 4px; scrollbar-width: none;
  scroll-padding-inline: 20px;
  -webkit-overflow-scrolling: touch;
}
.dates::-webkit-scrollbar { display: none; }

.date {
  flex: none;
  width: 58px; min-height: 66px;
  padding: 11px 0;
  border-radius: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.date.on { background: var(--accent); border-color: var(--accent); color: #0a0a0a; }

.dow { font-size: 9.5px; letter-spacing: 0.16em; text-transform: uppercase; opacity: 0.72; }
.dnum { font-family: var(--serif); font-size: 20px; line-height: 1; font-variant-numeric: tabular-nums; }

/* ── Time pills ───────────────────────────────────────────────────────────── */

.times { display: flex; flex-wrap: wrap; gap: 9px; }

.time {
  min-height: 44px;
  padding: 11px 17px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 14px;
  letter-spacing: 0.03em;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.time.on { background: var(--accent); border-color: var(--accent); color: #0a0a0a; font-weight: 600; }

/* ── Client information ───────────────────────────────────────────────────── */

.fields { display: grid; gap: 10px; }

.field {
  display: flex; align-items: center; gap: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 16px;
  transition: border-color 0.2s ease;
}
.field:focus-within { border-color: var(--accent); }

.field-icon {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: var(--muted); stroke-width: 1.3;
  stroke-linecap: round; stroke-linejoin: round;
  transition: stroke 0.2s ease;
}
.field:focus-within .field-icon { stroke: var(--accent); }

.field-input {
  flex: 1; min-width: 0;
  background: none; border: 0; outline: none;
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px; /* 16px stops iOS zooming on focus */
  padding: 16px 0;
}
.field-input::placeholder { color: var(--muted); }

/*
 * Safari/Chrome autofill.
 *
 * The dark surface lives on the parent .field — .field-input is transparent —
 * so there is no input background for the browser to respect, and autofill
 * paints its own white/pale-yellow fill straight over the design.
 *
 * `background-color` is ignored on an autofilled control; a large inset
 * box-shadow is the only thing that reliably covers it. It uses var(--surface),
 * the exact token .field is painted with, so the two can never drift apart —
 * including when a cloned build changes the theme.
 *
 * Nothing here touches the border, focus ring, icons or layout, and autofill
 * itself keeps working.
 */
.field-input:-webkit-autofill,
.field-input:-webkit-autofill:hover,
.field-input:-webkit-autofill:focus,
.field-input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 100px var(--surface) inset;
          box-shadow: 0 0 0 100px var(--surface) inset;
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
}

/* Standard selector, kept in its own rule: bundling it with the -webkit- one
   would make older parsers drop the entire block. */
.field-input:autofill,
.field-input:autofill:hover,
.field-input:autofill:focus,
.field-input:autofill:active {
  box-shadow: 0 0 0 100px var(--surface) inset;
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
}

.field-note {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 4px;
}
.linkish {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--accent); font-size: 12px; letter-spacing: 0.04em;
  text-underline-offset: 3px; text-decoration: underline;
}

/* ── Sticky booking bar ───────────────────────────────────────────────────── */

.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: rgba(10, 10, 10, 0.94);
  -webkit-backdrop-filter: saturate(140%) blur(16px);
  backdrop-filter: saturate(140%) blur(16px);
  border-top: 1px solid var(--hairline);
  padding: 14px 20px calc(14px + env(safe-area-inset-bottom));
}

.bar-row {
  max-width: 460px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
}
.bar-error { max-width: 460px; margin: 0 auto 10px; }

.bar-summary { flex: 1 1 auto; min-width: 0; }
.bar-when {
  font-family: var(--serif);
  font-size: 15px; line-height: 1.3; letter-spacing: 0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bar-what {
  font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--accent); margin-top: 3px;
}
.bar-empty {
  font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted); white-space: nowrap;
}

.cta {
  flex: none;
  background: var(--accent);
  color: #0a0a0a;
  border: 0; border-radius: 3px;
  padding: 15px 15px; min-height: 48px;
  font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.12s ease;
}
.cta:active:not(:disabled) { transform: scale(0.985); }
.cta:disabled { opacity: 0.28; cursor: default; }

/* ── Confirmation ─────────────────────────────────────────────────────────── */

.confirm { text-align: center; padding-top: 64px; }
.check {
  width: 56px; height: 56px; margin: 0 auto 26px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  color: var(--accent); font-size: 24px;
  display: flex; align-items: center; justify-content: center;
}
.confirm h1 {
  font-family: var(--serif); font-weight: 400;
  font-size: 27px; letter-spacing: 0.05em; text-transform: uppercase;
  margin: 0 0 20px;
}
.confirm-service { font-family: var(--serif); font-size: 20px; margin: 0 0 8px; }
.confirm-when {
  font-size: 11.5px; letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--accent); margin: 0 0 24px;
}
.ghost {
  margin-top: 30px; background: transparent;
  border: 1px solid var(--border); color: var(--muted);
  border-radius: 3px; padding: 13px 20px;
  font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  cursor: pointer;
}
.ghost.accent { color: var(--accent); border-color: var(--accent); }

/* ── Add to Home Screen ───────────────────────────────────────────────────── */

.a2hs {
  position: fixed; left: 14px; right: 14px;
  bottom: calc(var(--bar-h) + 12px);
  max-width: 432px; margin: 0 auto; z-index: 20;
  background: var(--raised);
  border: 1px solid var(--border); border-radius: 5px;
  padding: 15px 15px 13px;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.7);
}
.a2hs-row { display: flex; align-items: flex-start; gap: 10px; }
.a2hs-text { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.a2hs-text strong {
  font-size: 11px; font-weight: 600; letter-spacing: 0.15em; text-transform: uppercase;
}
.a2hs-text span { font-size: 12.5px; color: var(--muted); }
.a2hs-x { background: none; border: 0; color: var(--muted); font-size: 20px; line-height: 1; padding: 0 2px; cursor: pointer; }
.a2hs-steps { margin-top: 11px; }
.a2hs-steps ol { margin: 0; padding-left: 17px; color: var(--muted); font-size: 12.5px; line-height: 1.6; }
.a2hs-steps strong { color: var(--text); }
.a2hs-actions { display: flex; gap: 8px; margin-top: 13px; }
.a2hs-primary {
  flex: 1; background: var(--accent); color: #0a0a0a;
  border: 0; border-radius: 3px; padding: 12px;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  cursor: pointer;
}
.a2hs-ghost {
  flex: 1; background: transparent; color: var(--muted);
  border: 1px solid var(--border); border-radius: 3px; padding: 12px;
  font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase;
  cursor: pointer;
}

/* ── Motion preferences ───────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* Very narrow phones (iPhone SE): keep the summary from clipping. */
@media (max-width: 360px) {
  .wrap { padding-left: 16px; padding-right: 16px; }
  .bar { padding-left: 16px; padding-right: 16px; }
  /* Stack rather than squeeze — the summary must never truncate. */
  .bar-row { flex-direction: column; align-items: stretch; gap: 11px; }
  .bar-summary { text-align: center; }
  .bar-when { font-size: 15px; }
  .cta { width: 100%; }
  .brand { font-size: 26px; }
  .service-name, .service-price { font-size: 18.5px; }
}
