/* main.css — self-contained styles for the standalone Daily Report
   Generator. Written independently; references ConstruDo's existing
   public visual identity (blueprint-blue accent, clean neutral background,
   system-font headings) as inspiration only — nothing here imports or
   copies landing/'s shared stylesheet or partials. */

:root {
  --paper: #f4f6f5;
  --panel: #ffffff;
  --ink: #1a2b33;
  --mute: #52666c;
  --line: #d7dedc;
  --accent: #2b5c7a;
  --accent-dark: #1f4a63;
  --accent-contrast: #ffffff;
  --danger: #a3372b;
  --danger-bg: #fbeceA;
  --focus-ring: #2b5c7a;
  --radius: 8px;
  --max-width: 1180px;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-body: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #121a1e;
    --panel: #182229;
    --ink: #e7eeec;
    --mute: #93a6ab;
    --line: #28363c;
    --accent: #76b6db;
    --accent-dark: #5b9bc2;
    --accent-contrast: #0c1418;
    --danger: #e2958a;
    --danger-bg: #2a1a18;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15.5px;
  line-height: 1.55;
}

.shell { max-width: var(--max-width); margin: 0 auto; padding: 0 20px; }

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 8px 14px;
  z-index: 100;
}
.skip-link:focus { left: 8px; top: 8px; }

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

/* ---- header / footer --------------------------------------------------- */

.site-header { border-bottom: 1px solid var(--line); background: var(--panel); }
.header-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; gap: 16px; flex-wrap: wrap; }
.wordmark { font-family: var(--font-ui); font-weight: 800; font-size: 18px; margin: 0; display: flex; align-items: center; flex-wrap: wrap; gap: 0; }
.wordmark-link { display: inline-flex; align-items: center; gap: 9px; color: inherit; text-decoration: none; }
.wordmark-link:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; border-radius: 4px; }
.logo-mark { width: 30px; height: 29px; border-radius: 6px; flex-shrink: 0; display: block; }
.wordmark-tool { font-weight: 500; color: var(--mute); }

.header-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* Badges reuse construdo.com's own crop technique: both app-store-badge.png
   and google-play-badge.png bake in transparent padding, and not by the
   same proportion in each direction, so a naive uniform <img height> makes
   the two visible glyphs render at different heights. Each is instead a
   background-image sized by scale (targetHeight / contentHeight — content
   box measured directly from the source PNGs' opaque pixels) inside a box
   matching that badge's own content aspect ratio — same math, same source
   files as scripts/resources/partials.js's badgeBox()/BADGE_SPECS, just a
   smaller target height (32px desktop / 26px mobile) to fit this tool's
   more compact header than the full marketing nav. If either PNG is ever
   replaced, these four numbers need re-measuring. */
.badge-crop { display: block; background-repeat: no-repeat; background-position: center center; border-radius: 4px; }
.badge-appstore { width: 95.67px; height: 32px; background-image: url(../assets/img/app-store-badge.png); background-size: auto 82.9px; }
.badge-playstore { width: 107.43px; height: 32px; background-image: url(../assets/img/google-play-badge.png); background-size: auto 47.62px; }

@media (max-width: 560px) {
  .header-row { padding: 12px 16px; gap: 10px; }
  .logo-mark { width: 24px; height: 23px; }
  .wordmark { font-size: 15px; }
  .header-actions { gap: 8px; }
  .badge-appstore { width: 77.73px; height: 26px; background-size: auto 67.36px; }
  .badge-playstore { width: 87.29px; height: 26px; background-size: auto 38.69px; }
  .header-actions .btn-ghost { padding: 7px 12px; font-size: 12.5px; }
}

.site-footer { border-top: 1px solid var(--line); margin-top: 48px; padding: 20px 0 40px; color: var(--mute); font-size: 13px; }

/* ---- buttons ------------------------------------------------------------ */

.btn {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 14px;
  border-radius: 100px;
  padding: 10px 18px;
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  min-height: 40px;
}
.btn:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
.btn-primary { background: var(--accent); color: var(--accent-contrast); }
.btn-primary:hover { background: var(--accent-dark); }
.btn-ghost { background: transparent; color: var(--accent); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--accent); }
.btn-add { background: var(--panel); color: var(--ink); border-color: var(--line); font-size: 13.5px; padding: 8px 14px; min-height: 36px; }
.btn-add:hover { border-color: var(--accent); color: var(--accent); }
.btn-remove { background: transparent; color: var(--danger); border: none; font-size: 13px; padding: 6px 10px; }
.btn-danger { background: var(--danger); color: #fff; }

/* ---- hero --------------------------------------------------------------- */

.hero { padding: 40px 20px 20px; }
.hero h1 { font-family: var(--font-ui); font-size: clamp(26px, 4vw, 36px); font-weight: 800; margin: 0 0 10px; text-wrap: balance; }
.hero-dek { max-width: 62ch; color: var(--mute); font-size: 16.5px; margin: 0 0 6px; }
.hero-meta { font-family: var(--font-ui); font-size: 12.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); font-weight: 700; margin: 10px 0 0; }

/* ---- workspace (form + preview) ----------------------------------------- */

.workspace { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 24px; align-items: start; padding: 20px 20px 0; }
@media (max-width: 920px) {
  .workspace { grid-template-columns: 1fr; padding-left: 8px; padding-right: 8px; }
}

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.preview-panel { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; }
@media (max-width: 920px) { .preview-panel { position: static; max-height: none; } }

.preview-heading { margin: 0 0 12px; font-family: var(--font-ui); font-size: 15px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--mute); }
.preview-root h3 { margin: 0 0 10px; font-size: 19px; }
.preview-root h4 { margin: 20px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--accent); border-top: 1px solid var(--line); padding-top: 14px; }
.pv-line { margin: 2px 0; font-size: 13.5px; }
.pv-label { color: var(--mute); }
.pv-totals { font-weight: 700; font-size: 13px; margin: 6px 0 0; }
/* Scoped scroll container: if a cell's content still can't be squeezed
   into the available width (table-layout: fixed + word-break below
   handle the normal case), this scrolls *within the preview panel only*
   — the table's own min-width is the floor below which columns would
   become unreadably narrow, so this is the deliberate fallback past that
   floor, not the primary wrapping strategy. The page body itself never
   gains a scrollbar from this. */
.pv-table-wrap { overflow-x: auto; max-width: 100%; margin-bottom: 8px; -webkit-overflow-scrolling: touch; }
.pv-table { width: 100%; min-width: 360px; border-collapse: collapse; table-layout: fixed; font-size: 12.5px; margin-bottom: 0; }
.pv-table th { text-align: left; color: var(--mute); font-weight: 600; border-bottom: 1px solid var(--line); padding: 4px 6px; overflow-wrap: anywhere; word-break: break-word; }
.pv-table td { padding: 4px 6px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; word-break: break-word; }
.pv-notes { margin: 0 0 8px; padding-left: 18px; font-size: 13px; }
.pv-photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; }
.pv-photo-grid img { width: 100%; height: 64px; object-fit: cover; border-radius: 4px; }

/* ---- form ----------------------------------------------------------------- */

fieldset.field-section { border: none; border-top: 1px solid var(--line); margin: 0; padding: 20px 0; }
fieldset.field-section:first-of-type { border-top: none; padding-top: 0; }
legend {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 15px;
  padding: 0;
  margin-bottom: 10px;
}
.section-help { color: var(--mute); font-size: 13px; margin: -4px 0 12px; }

details.collapsible { border-top: 1px solid var(--line); padding: 16px 0; }
details.collapsible summary {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  padding: 2px 0;
}
details.collapsible summary:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 3px; }
.collapsible-body { padding-top: 14px; }
.subhead { font-size: 13.5px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--mute); margin: 18px 0 8px; }
.subhead:first-child { margin-top: 0; }

.field-grid { display: grid; gap: 14px; }
.field-grid.two-col { grid-template-columns: 1fr 1fr; }
@media (max-width: 560px) { .field-grid.two-col { grid-template-columns: 1fr; } }
.field-span-2 { grid-column: span 2; }
@media (max-width: 560px) { .field-span-2 { grid-column: span 1; } }

.field label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--mute); }
.field .req { color: var(--danger); }

input[type="text"], input[type="date"], input[type="number"], select {
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px 12px;
  min-height: 44px; /* touch target */
  width: 100%;
}
input:focus-visible, select:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 1px; }
input[aria-invalid="true"] { border-color: var(--danger); background: var(--danger-bg); }

/* ---- repeatable row cards --------------------------------------------- */

.row-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.row-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.row-grid { display: grid; gap: 10px; }
.row-grid-1 { grid-template-columns: 1fr; }
.row-grid-2 { grid-template-columns: 1fr 1fr; }
.row-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.row-grid-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
@media (max-width: 640px) {
  .row-grid-2, .row-grid-3, .row-grid-4 { grid-template-columns: 1fr; }
}
.row-card .btn-remove { align-self: flex-end; }
.empty-state { color: var(--mute); font-size: 13.5px; font-style: italic; margin: 0 0 10px; }

/* ---- photos -------------------------------------------------------------- */

.photo-upload { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.photo-upload-label { cursor: pointer; }
.photo-upload-status { font-size: 13px; color: var(--mute); }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.photo-card {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.photo-card img { width: 100%; height: 110px; object-fit: cover; border-radius: 4px; background: var(--paper); }
.photo-card input { font-size: 13px; padding: 7px 9px; min-height: 36px; }
.photo-meta { font-size: 11.5px; color: var(--mute); margin: 0; font-variant-numeric: tabular-nums; }

/* ---- actions / status --------------------------------------------------- */

.action-row { display: flex; gap: 12px; align-items: center; padding-top: 16px; flex-wrap: wrap; }
.reset-confirm { display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.reset-confirm-text { font-size: 13.5px; color: var(--mute); }
.download-status { min-height: 1.4em; font-size: 13.5px; color: var(--accent); font-weight: 600; margin: 8px 0 0; }
.form-errors { background: var(--danger-bg); border: 1px solid var(--danger); border-radius: 6px; padding: 12px 14px; margin-bottom: 16px; font-size: 13.5px; }
.form-errors p { margin: 0 0 4px; font-weight: 700; }
.form-errors ul { margin: 0; padding-left: 18px; }

/* ---- CTA / about / FAQ bands -------------------------------------------- */

.cta-band, .about-band, .faq-band { padding: 36px 20px; border-top: 1px solid var(--line); max-width: var(--max-width); margin: 0 auto; }
.cta-band h2, .about-band h2, .faq-band h2 { font-family: var(--font-ui); font-size: 22px; margin: 0 0 10px; }
.cta-band p, .about-band p { max-width: 68ch; color: var(--mute); }
.cta-band .btn { margin-top: 12px; }
.faq-list { margin: 0; }
.faq-item { margin-bottom: 16px; max-width: 68ch; }
.faq-item dt { font-weight: 700; margin-bottom: 4px; }
.faq-item dd { margin: 0; color: var(--mute); }

a { color: var(--accent); }

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