/* Grønn Trøst — shared base styles.
   Locked tokens from ARCHITECTURE.md. Solid colors only: no gradients,
   no rgba washes, no shadows. Fonts loaded per page via Google Fonts:

   <link rel="preconnect" href="https://fonts.googleapis.com">
   <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
   <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Figtree:wght@400;600;700&family=Young+Serif&display=swap">
*/

:root {
  --green: #123B2E;
  --cream: #F3E9D8;
  --cream-light: #FBF4EA;
  --rust: #8E3B2F;
  --ink: #241D18;
  --white: #FFFFFF;

  /* Derived solid tones (hover/lines/secondary text) */
  --green-dark: #0D2C22;
  --rust-dark: #6F2E24;
  --line: #E3D5BF;
  --line-strong: #A79A87;
  --muted: #6E5F52;
  --cream-on-green: #D9CCB2;
  --disabled-bg: #E9DEC9;

  --font-heading: 'Young Serif', Georgia, serif;
  --font-body: 'Figtree', 'Segoe UI', system-ui, sans-serif;

  --radius-card: 12px;
  --radius-input: 10px;
  --radius-pill: 999px;
  --touch: 48px;
}

* { box-sizing: border-box; }

/* The hidden attribute must always win, also over display:flex classes
   (this is what hides the login screen and the map banner). */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 18px; /* accessibility floor */
  line-height: 1.6;
  color: var(--ink);
  background: var(--cream-light);
  overflow-wrap: break-word;
}

h1, h2, h3, h4 {
  font-family: var(--font-heading);
  font-weight: 400;
  line-height: 1.25;
  color: var(--green);
  margin: 0 0 0.5em;
}
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }

p { margin: 0 0 1em; }
a { color: var(--rust); }
a:hover { color: var(--rust-dark); }

:focus-visible {
  outline: 3px solid var(--rust);
  outline-offset: 2px;
  border-radius: 4px;
}
.on-green :focus-visible { outline-color: var(--cream); }

/* Programmatic focus targets (step headings, view containers) get focus for
   screen readers without a visible ring — they are never tab-reachable. */
[tabindex="-1"]:focus, [tabindex="-1"]:focus-visible { outline: none; }

/* ---------- layout helpers ---------- */

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px;
}
.container-wide { max-width: 1100px; }

.stack > * + * { margin-top: 16px; }
.stack-lg > * + * { margin-top: 32px; }

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--green);
  color: var(--white);
  padding: 12px 20px;
  border-radius: 0 0 var(--radius-input) 0;
  z-index: 100;
}
.skip-link:focus { left: 0; color: var(--white); }

/* ---------- cards ---------- */

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 24px;
}

.card-cream {
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 24px;
}

/* Selectable card (checkout product choice) */
.card-select {
  display: block;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.card-select:hover { border-color: var(--green); }
.card-select[aria-pressed="true"],
.card-select.selected {
  border: 2px solid var(--green);
  background: var(--cream-light);
}

/* ---------- buttons (pills) ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--touch);
  padding: 10px 28px;
  border-radius: var(--radius-pill);
  border: 2px solid transparent;
  font-family: var(--font-body);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

.btn-primary { background: var(--rust); color: var(--white); border-color: var(--rust); }
.btn-primary:hover { background: var(--rust-dark); border-color: var(--rust-dark); }

.btn-secondary { background: var(--white); color: var(--green); border-color: var(--green); }
.btn-secondary:hover { background: var(--cream-light); }

.btn-green { background: var(--green); color: var(--white); border-color: var(--green); }
.btn-green:hover { background: var(--green-dark); border-color: var(--green-dark); }

.btn-quiet { background: transparent; color: var(--green); border-color: transparent; text-decoration: underline; }
.btn-quiet:hover { color: var(--green-dark); }

.btn[disabled], .btn.disabled {
  background: var(--disabled-bg);
  color: var(--muted);
  border-color: var(--disabled-bg);
  cursor: not-allowed;
}

.btn-block { display: flex; width: 100%; }

/* ---------- forms ---------- */

label, .field-label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
}

.field-hint {
  color: var(--muted);
  font-size: 16px;
  margin: -2px 0 8px;
}

input[type="text"], input[type="email"], input[type="tel"],
input[type="number"], input[type="date"], select, textarea {
  width: 100%;
  min-height: var(--touch);
  padding: 10px 14px;
  font-family: var(--font-body);
  font-size: 18px;
  color: var(--ink);
  background: var(--white);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-input);
}
textarea { resize: vertical; min-height: 120px; }

input[type="checkbox"], input[type="radio"] {
  width: 24px;
  height: 24px;
  accent-color: var(--green);
  flex-shrink: 0;
}

.check-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.check-row label { font-weight: 400; margin: 0; }

.error-text { color: var(--rust); font-weight: 600; }

.field-error input, .field-error select, .field-error textarea { border-color: var(--rust); }

.char-counter { color: var(--muted); font-size: 16px; text-align: right; }

/* ---------- notices ---------- */

.notice {
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 16px 20px;
}
.notice-error {
  background: var(--white);
  border: 2px solid var(--rust);
  border-radius: var(--radius-card);
  padding: 16px 20px;
}

/* ---------- tables (CRM) ---------- */

table.data {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  overflow: hidden;
}
table.data th, table.data td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
table.data th {
  font-weight: 600;
  background: var(--cream);
  color: var(--green);
}
table.data tr:last-child td { border-bottom: 0; }

/* Phone: wrap any .data table in this to scroll instead of overflowing */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll table.data { min-width: 480px; }

/* ---------- badges (status) ---------- */

.badge {
  display: inline-block;
  padding: 2px 12px;
  border-radius: var(--radius-pill);
  font-family: var(--font-body); /* also inside headings */
  font-size: 15px;
  font-weight: 600;
  border: 1.5px solid;
}
.badge-green { color: var(--green); border-color: var(--green); background: var(--cream-light); }
.badge-rust { color: var(--rust); border-color: var(--rust); background: var(--white); }
.badge-muted { color: var(--muted); border-color: var(--line-strong); background: var(--cream-light); }
/* «Mest valgt» — same badge as on gronntrost.no: green with cream text */
.badge-strong {
  color: var(--cream); border-color: var(--green); background: var(--green);
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; vertical-align: middle;
}

/* ---------- CRM shell ---------- */

.crm-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.crm-sidebar {
  background: var(--green);
  color: var(--cream);
  display: flex;
  flex-direction: column;
  padding: 24px 0;
  min-width: 0; /* lets the phone nav scroll instead of widening the grid */
}
.crm-logo {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  color: var(--white);
  padding: 0 24px 20px;
}
.crm-nav { display: flex; flex-direction: column; flex: 1; }
.crm-nav a {
  display: block;
  padding: 12px 24px;
  color: var(--cream);
  text-decoration: none;
  font-weight: 600;
  border-left: 4px solid transparent;
  min-height: var(--touch);
}
.crm-nav a:hover { background: var(--green-dark); color: var(--white); }
.crm-nav a.active {
  background: var(--cream-light);
  color: var(--green);
  border-left-color: var(--rust);
}
.crm-sidebar-footer {
  padding: 16px 24px 0;
  font-size: 14px;
  color: var(--cream-on-green);
}

.crm-main { padding: 32px; min-width: 0; }
.crm-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.crm-user { color: var(--muted); font-size: 16px; }

/* Phone: sidebar becomes a top bar with horizontally scrollable nav */
@media (max-width: 900px) {
  .crm-layout { grid-template-columns: 1fr; }
  .crm-sidebar { padding: 12px 0 0; }
  .crm-logo { padding: 4px 16px 8px; }
  .crm-nav {
    flex-direction: row;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .crm-nav a {
    border-left: none;
    border-bottom: 4px solid transparent;
    padding: 10px 16px;
    white-space: nowrap;
  }
  .crm-nav a.active { border-bottom-color: var(--rust); border-left: none; }
  .crm-sidebar-footer { display: none; }
  .crm-main { padding: 20px 16px; }
}

/* ---------- map (Kart view) ---------- */

.map-container {
  height: 60vh;
  min-height: 380px;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  z-index: 0;
}

.grave-pin {
  display: block;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid var(--white);
  box-sizing: border-box;
}
.grave-pin.located { background: var(--green); }
.grave-pin.unknown { background: var(--rust); }

/* Church marker for a graveyard on the overview map (nav icon) */
.yard-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--white);
  border: 2px solid var(--green);
  color: var(--green);
  box-sizing: border-box;
}
.yard-icon svg { width: 20px; height: 20px; display: block; }

.map-hint {
  color: var(--muted);
  margin: 8px 0 0;
  font-size: 0.95rem;
}

.map-banner {
  background: var(--rust);
  color: var(--white);
  border-radius: var(--radius-card);
  padding: 12px 20px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.map-banner .btn { min-height: 40px; padding: 6px 20px; }

/* ---------- checkout header/progress ---------- */

.checkout-header {
  background: var(--green);
  color: var(--white);
  padding: 20px 16px;
  text-align: center;
}
.checkout-header .site-name {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  color: var(--white);
  margin: 0;
}
.progress-label {
  font-weight: 600;
  color: var(--green);
  margin: 24px 0 8px;
}
.progress-track {
  display: flex;
  gap: 6px;
  margin-bottom: 24px;
}
.progress-track span {
  flex: 1;
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--line);
}
.progress-track span.done { background: var(--green); }

@media (max-width: 480px) {
  h1 { font-size: 1.6rem; }
  .crm-main, .card, .card-cream { padding: 20px 16px; }
}

/* ---------- print (season shopping list etc.) ---------- */

@media print {
  body { background: #fff; font-size: 12pt; color: #000; }
  .crm-sidebar, .crm-topbar, .skip-link { display: none !important; }
  .crm-layout { display: block; min-height: 0; }
  .crm-main { padding: 0; }
  .btn, .notice { display: none !important; }
  .card, table.data { border-color: #888; }
  table.data th { background: #eee; color: #000; }
  a { color: #000; text-decoration: none; }
  /* When printing via the shopping list button, show only the list */
  body.print-shopping-only #crm-content > *:not(#season-shopping) { display: none !important; }
  body.print-shopping-only #season-shopping .btn { display: none !important; }
}
