/* ─── Design tokens ──────────────────────────────────────────────────── */
:root {
  /* Fractex palette */
  --paper:          #FAFAF7;
  --ink:            #0E0E10;
  --signal:         #5C2D91;
  --signal-hover:   #6D3AA8;
  --signal-pale:    #F0EAF8;
  --cream:          #F3EDE3;
  --stone:          #E0DCD5;
  --ash:            #8A8885;

  /* Mapped tokens */
  --bg:             var(--paper);
  --surface:        #FFFFFF;
  --surface-alt:    var(--cream);
  --border:         var(--stone);
  --border-strong:  #C5C1B9;

  --text:           var(--ink);
  --text-muted:     var(--ash);
  --text-faint:     #B5B2AD;

  --accent:         var(--signal);
  --accent-hover:   var(--signal-hover);
  --accent-pale:    var(--signal-pale);
  --accent-text:    #FFFFFF;

  --busy-bg:        #ECEAE5;
  --busy-text:      #ADABA5;

  --success-bg:     #EBF5EE;
  --success-text:   #1A5C38;
  --error-bg:       #FCECEA;
  --error-text:     #B5201A;

  --radius-sm:      5px;
  --radius:         9px;
  --radius-lg:      14px;

  --shadow-sm:      0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow:         0 4px 16px rgba(0,0,0,.08), 0 1px 4px rgba(0,0,0,.04);
  --shadow-focus:   0 0 0 3px rgba(92,45,145,.22);

  --transition:     160ms ease;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI',
    system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100dvh;
}

/* ─── Display headings — Anybody Black 80% ───────────────────────────── */
h1, h2, h3,
.admin-header-text h1,
.modal h2 {
  font-family: 'Anybody', sans-serif;
  font-weight: 900;
  font-stretch: 80%;
  letter-spacing: -0.025em;
}

/* ─── Layout ─────────────────────────────────────────────────────────── */
.page {
  max-width: 860px;
  margin: 0 auto;
  padding: 56px 24px 80px;
}

.page-narrow {
  max-width: 560px;
  margin: 0 auto;
  padding: 56px 24px 80px;
}

/* ─── Founder avatar ─────────────────────────────────────────────────── */
.founder-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  margin-bottom: 20px;
  background: var(--signal);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.founder-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.founder-initials {
  font-family: 'Anybody', sans-serif;
  font-weight: 900;
  font-stretch: 80%;
  color: #fff;
  font-size: 19px;
  letter-spacing: -0.02em;
  user-select: none;
}

/* ─── Header ─────────────────────────────────────────────────────────── */
.site-header {
  margin-bottom: 52px;
}

.site-header .eyebrow {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--signal);
  margin-bottom: 8px;
  font-family: 'IBM Plex Mono', monospace;
}

.site-header h1 {
  font-size: clamp(28px, 5vw, 40px);
  line-height: 1.1;
  color: var(--text);
}

.site-header .subtitle {
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 15px;
  max-width: 420px;
  line-height: 1.6;
}

/* ─── Section labels ─────────────────────────────────────────────────── */
.section-label {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 16px;
  font-family: 'IBM Plex Mono', monospace;
}

/* ─── Slot grid (index.html) ─────────────────────────────────────────── */
.slots-section { margin-bottom: 48px; }

.slots-empty {
  padding: 32px 0;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.6;
}

.slots-grid {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.slot-day-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.slot-day-heading {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .01em;
  text-transform: none;
  color: var(--text);
  font-family: inherit;
  margin: 0;
}

.slot-day-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.slot-card {
  --card-color: #555;
  background: var(--card-color);
  border: none;
  border-radius: var(--radius);
  padding: 16px 22px;
  cursor: pointer;
  transition: filter var(--transition), transform var(--transition), box-shadow var(--transition);
  user-select: none;
  position: relative;
  min-width: 90px;
  text-align: center;
}

.slot-card:hover {
  filter: brightness(1.15);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,.4);
}

.slot-card:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.slot-card.selected {
  filter: brightness(1.25);
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0,0,0,.5);
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.slot-card .slot-time {
  display: block;
  font-size: 22px;
  font-family: 'Anybody', sans-serif;
  font-weight: 900;
  font-stretch: 80%;
  letter-spacing: -0.02em;
  color: #fff;
}

/* ─── Booking form ───────────────────────────────────────────────────── */
.booking-form-section {
  border-top: 1px solid var(--border);
  padding-top: 36px;
}

.signout-footer {
  display: flex;
  justify-content: flex-end;
  padding: 24px 0 16px;
}

.signout-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  font-family: 'IBM Plex Mono', monospace;
  cursor: pointer;
  padding: 4px 0;
  transition: color var(--transition);
}

.signout-btn:hover {
  color: var(--text);
}

.form-group {
  margin-bottom: 18px;
}

label {
  display: block;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-family: 'IBM Plex Mono', monospace;
}

input[type="text"],
input[type="email"],
textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  font-size: 15px;
  font-family: 'IBM Plex Sans', sans-serif;
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
  -webkit-appearance: none;
}

input[type="text"]:focus,
input[type="email"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--signal);
  box-shadow: var(--shadow-focus);
}

textarea {
  resize: vertical;
  min-height: 90px;
  line-height: 1.6;
}

::placeholder { color: var(--text-faint); }

/* ─── Buttons ────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 24px;
  font-size: 14px;
  font-weight: 500;
  font-family: 'IBM Plex Sans', sans-serif;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition),
    box-shadow var(--transition), opacity var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-primary:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

.btn-primary:disabled {
  opacity: .38;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--surface-alt);
}

.btn-secondary:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

.btn-secondary:disabled {
  opacity: .38;
  cursor: not-allowed;
}

/* ─── Inline messages ────────────────────────────────────────────────── */
.message {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 1.5;
  margin-top: 16px;
}

.message-success {
  background: var(--success-bg);
  color: var(--success-text);
}

.message-error {
  background: var(--error-bg);
  color: var(--error-text);
}

.message-info {
  background: var(--signal-pale);
  color: var(--signal);
}

.hidden { display: none !important; }

/* ─── Confirmation panel ─────────────────────────────────────────────── */
.confirmation {
  padding: 48px 0;
}

.confirmation .check {
  width: 48px;
  height: 48px;
  background: var(--signal-pale);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
}

.confirmation .check svg { color: var(--signal); }

.confirmation h2 {
  font-size: 26px;
  line-height: 1.1;
  margin-bottom: 10px;
}

.confirmation p {
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.6;
  margin-bottom: 6px;
}

.confirmation .detail-label {
  color: var(--text-faint);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 500;
  margin-top: 28px;
  margin-bottom: 4px;
  font-family: 'IBM Plex Mono', monospace;
}

.confirmation .detail-value {
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
}

/* ─── Loading state ──────────────────────────────────────────────────── */
.loading-state {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 14px;
  padding: 24px 0;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--signal);
  border-radius: 50%;
  animation: spin .65s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Admin modal ────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(14,14,16,.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow);
}

.modal h2 {
  font-size: 22px;
  line-height: 1.1;
  margin-bottom: 6px;
}

.modal p {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.modal .form-group { margin-bottom: 16px; }

/* ─── Admin page layout ──────────────────────────────────────────────── */
.admin-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 36px;
  flex-wrap: wrap;
}

.admin-header-text h1 {
  font-size: 24px;
  line-height: 1.1;
  margin-bottom: 4px;
}

.admin-header-text p {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ─── Admin week navigator ───────────────────────────────────────────── */
.week-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.week-nav-label {
  font-size: 14px;
  font-weight: 500;
  min-width: 160px;
  text-align: center;
  font-family: 'IBM Plex Mono', monospace;
}

/* ─── Admin time grid ────────────────────────────────────────────────── */
.grid-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  margin-bottom: 28px;
}

.time-grid {
  display: grid;
  min-width: 560px;
  border-collapse: collapse;
}

.grid-header-row,
.grid-row {
  display: contents;
}

.grid-time-label {
  padding: 0 12px 0 14px;
  font-size: 11px;
  color: var(--text-faint);
  font-weight: 500;
  letter-spacing: .03em;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  white-space: nowrap;
  border-right: 1px solid var(--border);
  min-height: 36px;
  background: var(--bg);
  position: sticky;
  left: 0;
  z-index: 2;
  font-family: 'IBM Plex Mono', monospace;
}

.grid-corner {
  background: var(--bg);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  position: sticky;
  left: 0;
  z-index: 3;
}

.grid-day-header {
  padding: 12px 8px 10px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 1;
}

.grid-day-header:last-child { border-right: none; }

.grid-day-name {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text-muted);
  display: block;
  font-family: 'IBM Plex Mono', monospace;
}

.grid-day-number {
  font-size: 18px;
  font-family: 'Anybody', sans-serif;
  font-weight: 900;
  font-stretch: 80%;
  letter-spacing: -0.02em;
  color: var(--text);
  display: block;
  line-height: 1.2;
}

.grid-day-header.today .grid-day-number {
  color: var(--signal);
}

.grid-day-header.saturday .grid-day-name,
.grid-day-header.saturday .grid-day-number {
  color: #C9A84C;
}

.grid-day-header.sunday .grid-day-name,
.grid-day-header.sunday .grid-day-number {
  color: #C96060;
}

.grid-cell {
  min-height: 36px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
  position: relative;
}

.grid-cell:last-child { border-right: none; }

.grid-row:last-child .grid-cell,
.grid-row:last-child .grid-time-label { border-bottom: none; }

.grid-cell.free:hover { background: var(--signal-pale); }

.grid-cell.selected {
  background: var(--accent);
}

.grid-cell.selected::after {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 3px;
  background: rgba(255,255,255,.2);
}

.grid-cell.busy {
  background: var(--busy-bg);
  cursor: not-allowed;
  background-image: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 4px,
    rgba(0,0,0,.03) 4px,
    rgba(0,0,0,.03) 8px
  );
}

.grid-cell.past {
  background: var(--surface-alt);
  cursor: not-allowed;
  opacity: .6;
}

/* ─── Admin footer bar ───────────────────────────────────────────────── */
.admin-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.slot-counter {
  font-size: 14px;
  color: var(--text-muted);
  font-family: 'IBM Plex Mono', monospace;
}

.slot-counter strong {
  color: var(--text);
  font-weight: 600;
}

.slot-counter.at-max strong { color: var(--signal); }

/* ─── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .page, .page-narrow {
    padding: 36px 16px 64px;
  }

  .site-header { margin-bottom: 36px; }
  .site-header h1 { font-size: 26px; }

  .admin-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-footer .btn { width: 100%; justify-content: center; }

  .modal { padding: 28px 20px; }
}
