/* ============================================================
   Daybook — Design System (functional pages)
   ----------------------------------------------------------------
   Brand kit for the non-marketing pages: privacy, terms, dpa,
   popia-request, onboard, dashboard. Loads the same fonts, colors
   and primary type/button styles as the marketing site, without
   the 3D / WebGL machinery that lives only on index.html.
   ============================================================ */

/* -------- Font faces (relative to /public/design-system.css) -- */
@font-face {
  font-family: "Feature Display";
  font-weight: 200;
  font-style: normal;
  font-display: swap;
  src: url("/fonts/FeatureDisplay-Extralight.woff2") format("woff2");
}
@font-face {
  font-family: "Feature Display";
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  src: url("/fonts/FeatureDisplay-Regular.woff2") format("woff2");
}
@font-face {
  font-family: "Britti Sans";
  font-weight: 300;
  font-style: normal;
  font-display: swap;
  src: url("/fonts/BrittiSans-Light.woff2") format("woff2");
}
@font-face {
  font-family: "Britti Sans";
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  src: url("/fonts/BrittiSans-Regular.woff2") format("woff2");
}
@font-face {
  font-family: "Britti Sans";
  font-weight: 600;
  font-style: normal;
  font-display: swap;
  src: url("/fonts/BrittiSans-Semibold.woff2") format("woff2");
}

/* -------- Design tokens -------------------------------------- */
:root {
  /* Type families */
  --default-font: "Britti Sans", -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, Helvetica, Arial, sans-serif;
  --header-font: "Feature Display", "New York", "Georgia", "Times New Roman", serif;

  /* Brand palette */
  --color-white: #fbfff4;
  --color-black: #333338;
  --color-pure-white: #ffffff;
  --color-pure-black: #000000;
  --color-dark-link: #516e5a;
  --color-dark-link-2: #62866d;
  --color-dark-green: #203727;
  --color-light-green: #e0ffab;
  --color-light-green2: #bccca2;

  /* Type scale (clamp-style, calmer than the marketing site) */
  --h1: clamp(40px, 6.4vw, 84px);
  --h2: clamp(28px, 3.6vw, 44px);
  --h3: clamp(22px, 2.4vw, 28px);
  --sub1: clamp(16px, 1.4vw, 20px);
  --sub2: clamp(15px, 1.1vw, 17px);
  --body1: clamp(15px, 1.1vw, 17px);
  --body2: clamp(13px, 0.95vw, 15px);
  --btn1: 15px;
  --btn2: 15px;
  --link-footer: 14px;

  /* Functional tokens used by legal/forms */
  --ink: var(--color-black);
  --bg: var(--color-pure-white);
  --shade: #f4f8ee;
  --line: #d9e2cf;
  --muted: #6f7d72;
  --green: var(--color-dark-green);
  --green-soft: #eaf6dc;
  --red: #b53636;
  --red-soft: #fbecec;
  --radius: 12px;
  --radius-pill: 999px;
}

/* -------- Reset + base --------------------------------------- */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--default-font);
  font-size: var(--body1);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection { background: var(--color-light-green); color: var(--color-dark-green); text-shadow: none; }
::-moz-selection { background: var(--color-light-green); color: var(--color-dark-green); text-shadow: none; }

a {
  color: var(--color-dark-green);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  transition: color 0.18s ease;
}
a:hover { color: var(--color-dark-link-2); }

/* -------- Typography classes -------------------------------- */
h1, h2, h3, .h {
  font-family: var(--header-font);
  font-weight: 200;
  margin: 0;
  padding: 0;
  line-height: 1.05;
  letter-spacing: -0.01em;
  color: var(--ink);
}
h1 { font-size: var(--h1); line-height: 1; margin: 0 0 18px; }
h2 { font-size: var(--h2); line-height: 1.1; margin: 56px 0 14px; }
h3 { font-size: var(--h3); line-height: 1.15; margin: 32px 0 10px; font-weight: 400; }

p { margin: 0 0 14px; }

.sub1, .sub2 {
  font-family: var(--header-font);
  font-weight: 400;
}
.sub1 { font-size: var(--sub1); }
.sub2 { font-size: var(--sub2); }

.body1 {
  font-family: var(--default-font);
  font-weight: 300;
  font-size: var(--body1);
}
.body2 {
  font-family: var(--default-font);
  font-weight: 400;
  font-size: var(--body2);
}

.btn1 {
  font-family: var(--default-font);
  font-weight: 600;
  font-size: var(--btn1);
}
.btn2 {
  font-family: var(--header-font);
  font-weight: 400;
  font-size: var(--btn2);
}

.preloader {
  font-family: var(--header-font);
  font-weight: 200;
}

.link-footer {
  font-family: var(--default-font);
  font-weight: 600;
  font-size: var(--link-footer);
  color: var(--color-dark-link);
  text-decoration: none;
  transition: color 0.18s ease;
}
.link-footer:hover { color: var(--color-dark-link-2); }

.muted { color: var(--muted); }
.tagline {
  font-family: var(--header-font);
  font-weight: 400;
  font-size: clamp(17px, 1.6vw, 22px);
  color: var(--muted);
  margin: 0 0 36px;
  line-height: 1.35;
}

/* -------- Primary button (pill, brand light-green) ----------- */
.button {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.7em;
  height: 2.8em;
  padding: 0.4em 1.5em;
  border: 0;
  border-radius: var(--radius-pill);
  font-family: var(--default-font);
  font-weight: 600;
  font-size: var(--btn1);
  cursor: pointer;
  color: var(--color-dark-green);
  background: var(--color-light-green);
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  box-shadow: 0 1px 0 rgba(0,0,0,0.04);
}
.button:hover {
  transform: translateY(-1px);
  background: #c5e890;
  color: var(--color-dark-green);
  box-shadow: 0 8px 22px rgba(32, 55, 39, 0.16);
}
.button:active { transform: translateY(0); }
.button svg { width: 1em; height: 1em; fill: currentColor; }
.button.is-transparent {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.button.is-transparent:hover {
  background: var(--shade);
  border-color: var(--color-dark-link);
}
.button.is-dark {
  background: var(--color-dark-green);
  color: var(--color-white);
}
.button.is-dark:hover { background: #2d4f37; color: var(--color-white); }
.button:disabled,
.button[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
}

/* Legacy .btn class (used inline in onboard / dashboard / popia) ─ map to .button */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  height: 2.6em;
  padding: 0.4em 1.4em;
  border: 0;
  border-radius: var(--radius-pill);
  font-family: var(--default-font);
  font-weight: 600;
  font-size: var(--btn1);
  cursor: pointer;
  color: var(--color-dark-green);
  background: var(--color-light-green);
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.btn:hover {
  transform: translateY(-1px);
  background: #c5e890;
  color: var(--color-dark-green);
  box-shadow: 0 8px 22px rgba(32, 55, 39, 0.16);
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn.ghost:hover { background: var(--shade); border-color: var(--color-dark-link); }
.btn.danger { background: var(--red); color: #fff; }
.btn.danger:hover { background: #9c2d2d; color: #fff; }

/* -------- Layout containers ---------------------------------- */
.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 56px 24px 96px;
}
.wrap.wide { max-width: 1100px; }
.wrap.form { max-width: 820px; }

/* -------- Branded header (functional pages) ------------------ */
header.brand {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 44px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.brand .wordmark {
  font-family: var(--header-font);
  font-weight: 400;
  font-size: 26px;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.brand .wordmark a { color: inherit; text-decoration: none; }
.brand nav {
  display: flex;
  gap: 22px;
  font-size: 14px;
}
.brand nav a {
  text-decoration: none;
  color: var(--muted);
  font-family: var(--default-font);
  font-weight: 500;
  transition: color 0.18s ease;
}
.brand nav a:hover,
.brand nav a.active { color: var(--ink); }

/* -------- Cards, forms, fields, tables ----------------------- */
.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin: 0 0 18px;
  background: var(--bg);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 18px;
}
.field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  font-family: var(--default-font);
}
.field input,
.field select,
.field textarea {
  font-family: var(--default-font);
  font-size: 15px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--color-dark-green);
  box-shadow: 0 0 0 3px rgba(224, 255, 171, 0.45);
}
.field textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.field input[type="file"] {
  font-size: 14px;
  padding: 10px 12px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: var(--shade);
  cursor: pointer;
}
.field input[type="file"]:hover { border-color: var(--color-dark-link); }
.field .hint { color: var(--muted); font-size: 13px; margin: 0; }

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 640px) { .grid { grid-template-columns: 1fr; } }

.row { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }

.section {
  border-top: 1px solid var(--line);
  padding-top: 24px;
  margin-top: 28px;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0;
  font-size: 14px;
  line-height: 1.5;
}
table th, table td {
  border: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}
table thead th {
  background: var(--shade);
  font-weight: 600;
  color: var(--ink);
  border-bottom: 2px solid var(--color-light-green2);
}
table tbody tr:nth-child(even) td { background: #fafdf5; }

/* -------- Plain-English callout (legal pages) ---------------- */
.plain-english {
  background: var(--green-soft);
  border-left: 3px solid var(--color-light-green2);
  padding: 14px 18px;
  margin: 14px 0 22px;
  border-radius: 0 8px 8px 0;
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
}
.plain-english .label {
  display: block;
  font-style: italic;
  font-weight: 600;
  color: var(--color-dark-green);
  margin-bottom: 4px;
  font-size: 13px;
  letter-spacing: 0.02em;
}
.plain-english p { margin: 0; }
.plain-english p + p { margin-top: 8px; }

/* Placeholder highlights — leave easy to find */
mark.placeholder {
  background: #fff3b0;
  border: 1px dashed #c4a000;
  padding: 1px 6px;
  border-radius: 3px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  color: #6b4f00;
}

/* Doc front-matter block (legal pages) */
.front-matter {
  background: var(--shade);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin: 0 0 36px;
  font-size: 14px;
}
.front-matter dl {
  margin: 0;
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 8px 16px;
}
.front-matter dt { color: var(--muted); }
.front-matter dd { margin: 0; color: var(--ink); }
@media (max-width: 560px) {
  .front-matter dl { grid-template-columns: 1fr; gap: 2px 0; }
  .front-matter dt { margin-top: 8px; }
}

/* Doc-control footer */
.doc-control {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 40px 0 24px;
  font-size: 13px;
  color: var(--muted);
  background: var(--shade);
}
.doc-control strong { color: var(--ink); }
.doc-control ul { list-style: none; padding-left: 0; margin: 8px 0 0; }
.doc-control li { margin: 2px 0; }

/* Legal-nav footer strip (privacy / terms / dpa) */
.legal-nav {
  margin-top: 40px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  font-size: 14px;
  color: var(--muted);
}
.legal-nav strong { color: var(--ink); margin-right: 6px; }
.legal-nav a { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }

/* Updated banner (legal pages) */
.updated-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin: 0 0 32px;
  background: var(--shade);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  color: var(--muted);
}
.updated-banner .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--color-dark-green);
}

/* Information Regulator block */
.regulator-block {
  background: var(--shade);
  border-left: 3px solid var(--muted);
  padding: 14px 18px;
  margin: 14px 0;
  border-radius: 0 6px 6px 0;
  font-size: 14px;
}
.regulator-block p { margin: 0; }
.regulator-block p + p { margin-top: 4px; }

/* Section dividers */
article hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 48px 0;
}

/* Skip link (a11y) */
.skip-link {
  position: absolute; left: -9999px; top: auto;
  width: 1px; height: 1px; overflow: hidden;
}
.skip-link:focus {
  position: fixed; left: 12px; top: 12px;
  width: auto; height: auto;
  padding: 10px 14px; background: var(--color-dark-green); color: #fff;
  z-index: 1000; border-radius: 6px; text-decoration: none;
}

/* -------- Article body (legal pages) ------------------------- */
article {
  font-size: 16px;
  line-height: 1.7;
}
article h2 { font-size: 28px; margin-top: 56px; }
article h3 {
  font-size: 17px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink);
  margin-top: 28px;
  font-weight: 600;
  font-family: var(--default-font);
}
article ul, article ol { padding-left: 22px; margin: 0 0 14px; }
article li { margin-bottom: 8px; }
article strong { font-weight: 600; }

/* -------- Dashboard helpers --------------------------------- */
.kv {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 14px;
}
.kv:last-child { border-bottom: 0; }
.kv .k { width: 180px; color: var(--muted); }
.kv .v { flex: 1; }

.note {
  background: var(--shade);
  border-left: 3px solid var(--color-light-green2);
  padding: 12px 16px;
  border-radius: 0 6px 6px 0;
  font-size: 14px;
  margin: 16px 0;
  color: var(--ink);
}

.log {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  background: #f5f9ef;
  padding: 14px 18px;
  border-radius: 10px;
  white-space: pre-wrap;
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  color: var(--ink);
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 14px 18px;
  background: var(--color-dark-green);
  color: var(--color-white);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.18);
  font-size: 14px;
  z-index: 1000;
  max-width: 360px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  font-family: var(--default-font);
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--red); }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  background: var(--green-soft);
  color: var(--color-dark-green);
}
.status-pill.error { background: var(--red-soft); color: var(--red); }
.status-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.meta { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }

footer {
  margin-top: 60px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

/* -------- Print stylesheet (legal pages) -------------------- */
@media print {
  body { background: #fff; color: #000; font-size: 11pt; }
  .brand nav, .skip-link, .updated-banner, .legal-nav { display: none; }
  .wrap { max-width: none; padding: 0; margin: 0; }
  .plain-english, .front-matter, .regulator-block, .doc-control {
    background: #fff !important; border-left: 1pt solid #000; color: #000;
  }
  .plain-english .label { color: #000; }
  table thead th, table tbody tr:nth-child(even) td { background: #fff !important; }
  table th, table td { border: 1pt solid #000; }
  mark.placeholder { background: #fff !important; border: 1pt dashed #000; color: #000; }
  a { color: #000; text-decoration: underline; }
  section, .plain-english, table, tr { page-break-inside: avoid; }
  h1, h2 { page-break-after: avoid; }
}

/* -------- Dark variant (dashboard) -------------------------- */
body.theme-dark {
  background: var(--color-dark-green);
  color: var(--color-white);
}
body.theme-dark header.brand {
  border-bottom-color: rgba(251, 255, 244, 0.15);
}
body.theme-dark .brand .wordmark,
body.theme-dark h1,
body.theme-dark h2,
body.theme-dark h3 { color: var(--color-white); }
body.theme-dark .brand nav a { color: rgba(251, 255, 244, 0.6); }
body.theme-dark .brand nav a:hover,
body.theme-dark .brand nav a.active { color: var(--color-light-green); }
body.theme-dark .tagline { color: rgba(251, 255, 244, 0.62); }
body.theme-dark .muted { color: rgba(251, 255, 244, 0.55); }
body.theme-dark .card {
  background: rgba(251, 255, 244, 0.04);
  border-color: rgba(251, 255, 244, 0.12);
}
body.theme-dark .field input,
body.theme-dark .field select,
body.theme-dark .field textarea {
  background: rgba(251, 255, 244, 0.06);
  border-color: rgba(251, 255, 244, 0.18);
  color: var(--color-white);
}
body.theme-dark .field input:focus,
body.theme-dark .field select:focus,
body.theme-dark .field textarea:focus {
  border-color: var(--color-light-green);
  box-shadow: 0 0 0 3px rgba(224, 255, 171, 0.18);
}
body.theme-dark .field label { color: rgba(251, 255, 244, 0.7); }
body.theme-dark .kv { border-bottom-color: rgba(251, 255, 244, 0.1); }
body.theme-dark .kv .k { color: rgba(251, 255, 244, 0.55); }
body.theme-dark .log {
  background: rgba(0, 0, 0, 0.22);
  border-color: rgba(251, 255, 244, 0.12);
  color: var(--color-white);
}
body.theme-dark .note {
  background: rgba(251, 255, 244, 0.05);
  color: var(--color-white);
}
body.theme-dark table thead th {
  background: rgba(224, 255, 171, 0.12);
  color: var(--color-light-green);
  border-bottom-color: var(--color-light-green2);
}
body.theme-dark table th,
body.theme-dark table td { border-color: rgba(251, 255, 244, 0.12); }
body.theme-dark table tbody tr:nth-child(even) td { background: rgba(251, 255, 244, 0.03); }
body.theme-dark .btn.ghost {
  border-color: rgba(251, 255, 244, 0.25);
  color: var(--color-white);
}
body.theme-dark .btn.ghost:hover {
  background: rgba(251, 255, 244, 0.08);
  border-color: var(--color-light-green);
}
body.theme-dark a { color: var(--color-light-green); }
body.theme-dark a:hover { color: var(--color-white); }
