/* Driveway Reports — Apple HIG-inspired styling: system font, grouped inset
   cards, hairline separators, system colours in light and dark. */

:root {
  color-scheme: light dark;
  --bg: #F2F2F7;
  --card: #FFFFFF;
  --label: #000000;
  --secondary: rgba(60, 60, 67, 0.6);
  --tertiary: rgba(60, 60, 67, 0.3);
  --separator: rgba(60, 60, 67, 0.29);
  --fill: rgba(120, 120, 128, 0.12);
  --fill-strong: rgba(120, 120, 128, 0.2);
  --blue: #007AFF;
  --blue-tint: rgba(0, 122, 255, 0.12);
  --red: #FF3B30;
  --green: #34C759;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 10px 30px rgba(0, 0, 0, 0.06);
  --radius: 22px;
  --radius-sm: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1C1C1E;
    --label: #FFFFFF;
    --secondary: rgba(235, 235, 245, 0.6);
    --tertiary: rgba(235, 235, 245, 0.3);
    --separator: rgba(84, 84, 88, 0.65);
    --fill: rgba(120, 120, 128, 0.24);
    --fill-strong: rgba(120, 120, 128, 0.36);
    --blue: #0A84FF;
    --blue-tint: rgba(10, 132, 255, 0.18);
    --red: #FF453A;
    --green: #30D158;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--label);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Inter, system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.page {
  max-width: 600px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px calc(40px + env(safe-area-inset-bottom));
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}

:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* Header ------------------------------------------------------------------ */

.header { padding: 4px 4px 8px; }

.toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--secondary);
}

/* Segmented control (language) */

.segmented {
  flex: 0 0 auto;
  display: inline-flex;
  padding: 2px;
  border-radius: 999px;
  background: var(--fill);
}

.segment {
  min-width: 40px;
  padding: 4px 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--secondary);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.segment[aria-pressed="true"] {
  background: var(--card);
  color: var(--label);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.large-title {
  margin: 0;
  font-size: 34px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.subtitle {
  margin: 8px 0 0;
  font-size: 15px;
  color: var(--secondary);
  max-width: 44ch;
}

/* Cards ------------------------------------------------------------------- */

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.composer {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Photo picker */

.photo-zone { position: relative; }

.photo-button {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--fill);
  color: var(--blue);
  overflow: hidden;
  cursor: pointer;
  position: relative;
  font: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.15s ease;
}

.photo-button:active { background: var(--fill-strong); }

.photo-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 16px;
  text-align: center;
}

.photo-icon { width: 40px; height: 40px; margin-bottom: 6px; }

.photo-empty-title { font-size: 17px; font-weight: 600; }

.photo-empty-sub { font-size: 13px; color: var(--secondary); }

.photo-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-remove {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.photo-remove svg { width: 18px; height: 18px; }

/* Grouped rows */

.rows {
  border-radius: var(--radius-sm);
  background: var(--card);
  border: 0.5px solid var(--separator);
  overflow: hidden;
}

.row {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 48px;
  padding: 6px 16px;
}

.row + .row {
  border-top: 0.5px solid var(--separator);
}

.row-label { flex: 0 0 auto; }

.row-input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  margin: 0;
  padding: 6px 0;
  border: 0;
  background: transparent;
  color: var(--label);
  font: inherit;
  text-align: right;
  outline: none;
}

.row-input::placeholder { color: var(--tertiary); }

#initials { text-transform: uppercase; letter-spacing: 0.04em; }

input[type="datetime-local"].row-input {
  -webkit-appearance: none;
  appearance: none;
  color: var(--blue);
  font-variant-numeric: tabular-nums;
}

input[type="datetime-local"]::-webkit-calendar-picker-indicator { opacity: 0.5; }

.row-textarea { padding: 10px 16px; }

textarea {
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--label);
  font: inherit;
  resize: none;
  outline: none;
  line-height: 1.4;
}

textarea::placeholder { color: var(--tertiary); }

.form-error {
  margin: 0;
  padding: 0 4px;
  font-size: 15px;
  color: var(--red);
}

/* Buttons */

.button {
  display: block;
  width: 100%;
  min-height: 50px;
  padding: 12px 20px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s ease, transform 0.1s ease;
}

.button:active { transform: scale(0.985); }

.button:disabled { opacity: 0.4; cursor: default; transform: none; }

.primary { background: var(--blue); color: #fff; }

.secondary { background: var(--blue-tint); color: var(--blue); margin-top: 20px; }

/* Timeline ---------------------------------------------------------------- */

.timeline-section { margin-top: 20px; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 4px 12px;
}

.section-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.add-button {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 122, 255, 0.35);
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.add-button svg {
  width: 20px;
  height: 20px;
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.add-button:active { transform: scale(0.92); }

.add-button[aria-expanded="true"] {
  background: var(--fill-strong);
  color: var(--label);
  box-shadow: none;
}

.add-button[aria-expanded="true"] svg { transform: rotate(45deg); }

.composer-wrap {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transform: translateY(-8px) scale(0.985);
  transform-origin: top center;
  transition:
    grid-template-rows 0.4s cubic-bezier(0.2, 0.8, 0.2, 1),
    opacity 0.28s ease,
    transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.composer-wrap.open {
  grid-template-rows: 1fr;
  opacity: 1;
  transform: none;
}

.composer-inner {
  min-height: 0;
  overflow: hidden;
}

.composer-wrap.settled .composer-inner { overflow: visible; }

.composer { margin-bottom: 20px; }

.timeline {
  position: relative;
  padding-left: 26px;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 12px;
  bottom: 12px;
  width: 2px;
  border-radius: 1px;
  background: var(--separator);
}

.timeline:empty::before { display: none; }

.day-title {
  margin: 20px 0 10px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--secondary);
}

.day-title:first-child { margin-top: 4px; }

.report {
  position: relative;
  margin-bottom: 12px;
}

.report::before {
  content: "";
  position: absolute;
  left: -23px;
  top: 22px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 3px var(--bg);
}

.report-card { padding: 14px 16px; }

.report-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
  background: linear-gradient(160deg, #5AC8FA, #007AFF);
}

.report-meta { min-width: 0; }

.report-time {
  display: block;
  font-size: 17px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.report-by {
  display: block;
  font-size: 13px;
  color: var(--secondary);
}

.report-comment {
  margin: 10px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.report-photo {
  display: block;
  margin-top: 12px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--fill);
}

.report-photo img {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: cover;
}

.empty {
  margin: 8px 0 0;
  padding: 28px 16px;
  text-align: center;
  color: var(--secondary);
  font-size: 15px;
}

.empty-title { margin: 0; font-size: 17px; font-weight: 600; color: var(--label); }
.empty-sub { margin: 4px 0 0; }

/* Lightbox ---------------------------------------------------------------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.94);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px calc(80px + env(safe-area-inset-bottom));
}

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
}

.lightbox-close {
  position: absolute;
  bottom: calc(24px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  min-width: 120px;
  padding: 12px 24px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}

/* Toast ------------------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  max-width: calc(100% - 32px);
  padding: 12px 20px;
  border-radius: 999px;
  background: rgba(30, 30, 32, 0.92);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  animation: toast-in 0.25s ease;
}

.toast.error { background: var(--red); }

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
  .button, .photo-button, .composer-wrap, .add-button, .add-button svg, .segment { transition: none; }
}
