/* ==========================================================================
   Client portal (my.haydnmcintyre.ca). Haydn's own client-facing brand, so it follows
   haydnmcintyre.ca: green-black ground, chalk text, brass accent, Cormorant Garamond over
   Hanken Grotesk. Light mode keeps the same family on a pale green-white ground, with the
   deep green as the accent because brass text does not read on a light ground.

   Phone first. No inline styles, no inline scripts: the CSP allows 'self' and Google Fonts.
   Does not share anything with app.css, which belongs to the CRM.

   Contrast (WCAG), computed. Dark: text on ground 15 or better, text-2 on surface 7.1,
   ink on brass 9.7, brass on surface 9.5, danger 7.5, success 8.8, line-ui on surface 3.5.
   Light: text 16.2, text-2 6.8 or better, white on accent 7.5, accent on ground 6.9,
   danger 5.7 or better, success 6.4, line-ui 3.5 or better on every surface.
   ========================================================================== */

:root {
  color-scheme: light dark;

  --bg:        light-dark(#F2F5F0, #0A100E);
  --surface:   light-dark(#FFFFFF, #0F1815);
  --raised:    light-dark(#E8EEE9, #131E1A);
  --text:      light-dark(#0F1A15, #ECF1EC);
  --text-2:    light-dark(#46594E, #93A79A);
  --text-3:    light-dark(#5E7266, #7D9285);
  --line:      light-dark(rgba(15, 26, 21, 0.13), rgba(236, 241, 236, 0.11));
  --line-ui:   light-dark(#6E8176, #5F7167);

  --accent:       light-dark(#1C5F4A, #E5B457);   /* buttons and links */
  --accent-hover: light-dark(#174D3C, #F3CF7C);
  --on-accent:    light-dark(#FFFFFF, #17130A);
  --brass:        light-dark(#B98C33, #E5B457);   /* decoration only, never text on light */
  --focus:        light-dark(#1C5F4A, #E5B457);

  --danger:   light-dark(#A93C2B, #F08C7A);
  --success:  light-dark(#1B6B4F, #57C9A2);

  --display: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --sans:    "Hanken Grotesk", ui-sans-serif, system-ui, sans-serif;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --gutter: 20px;
  --edge: max(var(--gutter), calc((100vw - 880px) / 2 + var(--gutter)));
  --tap: 48px;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}

/* One soft environment behind the page: green and brass light, drifting slowly. */
body::before {
  content: "";
  position: fixed; inset: -10%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(40% 36% at 78% 12%, light-dark(rgba(28, 95, 74, 0.12), rgba(28, 95, 74, 0.55)), transparent 70%),
    radial-gradient(34% 30% at 12% 82%, light-dark(rgba(185, 140, 51, 0.14), rgba(229, 180, 87, 0.12)), transparent 70%),
    radial-gradient(30% 26% at 88% 70%, light-dark(rgba(63, 217, 192, 0.07), rgba(63, 217, 192, 0.14)), transparent 70%);
  animation: drift 40s ease-in-out infinite alternate;
}

/* Fine grain over the flat ground, dark only. */
@media (prefers-color-scheme: dark) {
  body::after {
    content: "";
    position: fixed; inset: 0;
    z-index: 100;
    pointer-events: none;
    opacity: 0.045;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
    background-size: 190px 190px;
  }
}

@keyframes drift { to { transform: translate3d(2.5%, 2%, 0) scale(1.06); } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

[hidden] { display: none !important; }

a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); }
::selection { background: var(--brass); color: #17130A; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 4px; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

.skip {
  position: fixed; top: 10px; left: 10px; z-index: 200;
  padding: 12px 16px; border-radius: 8px;
  background: var(--accent); color: var(--on-accent);
  font-weight: 500; text-decoration: none;
  transform: translateY(-300%);
}
.skip:focus { transform: none; color: var(--on-accent); }

/* ---- Header and footer --------------------------------------------------- */
.head, .page, .foot { position: relative; z-index: 1; }

.head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 68px;
  padding: 8px var(--edge);
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: var(--tap);
  color: var(--text);
  font-weight: 500; font-size: 15px; letter-spacing: -0.01em;
  text-decoration: none;
}
.brand:hover { color: var(--text); }
.brand svg { display: block; height: 22px; width: auto; color: var(--brass); }

.nav { display: flex; align-items: center; gap: 4px; }
.nav a {
  display: inline-flex; align-items: center;
  min-height: var(--tap); padding: 0 12px;
  color: var(--text-2);
  font-size: 15px; text-decoration: none;
  position: relative;
  transition: color 0.2s;
}
.nav a:hover { color: var(--text); }
.nav a[aria-current="page"] { color: var(--text); }
.nav a[aria-current="page"]::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: 8px;
  height: 1px; background: var(--brass);
}

.foot {
  margin-top: auto;
  padding: 28px var(--edge) calc(28px + env(safe-area-inset-bottom));
  color: var(--text-2);
  font-size: 14px;
}
.foot a { display: inline-flex; align-items: center; min-height: 44px; color: var(--text-2); }
.foot a:hover { color: var(--text); }

/* ---- Page frame ----------------------------------------------------------- */
.page {
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 20px var(--gutter) 40px;
}
.page--narrow { max-width: 520px; }

.eyebrow {
  margin: 0 0 10px;
  color: var(--text-2);
  font-size: 13px; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase;
}

h1 {
  margin: 0 0 12px;
  font: 300 clamp(40px, 11vw, 64px)/1.04 var(--display);
  letter-spacing: -0.015em;
}
h1 em { font-style: italic; }
h2 { margin: 0; font: 500 17px/1.3 var(--sans); }
.lede { margin: 0 0 28px; max-width: 46ch; color: var(--text-2); font-size: 17px; }
.muted { color: var(--text-2); }
.small { font-size: 14px; }

/* ---- Cards ------------------------------------------------------------------ */
.stack { display: grid; gap: 16px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px 20px;
}
.card__label {
  margin: 0 0 12px;
  color: var(--text-2);
  font-size: 13px; font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase;
}
.card p { margin: 0; }
.card p + p { margin-top: 10px; }
.card .btn { margin-top: 16px; }

.big {
  margin: 0;
  font: 300 clamp(30px, 8vw, 40px)/1.1 var(--display);
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.grid { display: grid; gap: 16px; }
@media (min-width: 760px) {
  :root { --gutter: 40px; }
  .head { min-height: 76px; }
  .grid--two { grid-template-columns: 1fr 1fr; }
  .card { padding: 26px 26px; }
  .card--wide { grid-column: 1 / -1; }
}

.facts { display: grid; gap: 14px; margin: 0; }
.facts div { display: grid; gap: 2px; }
.facts dt { color: var(--text-2); font-size: 14px; }
.facts dd { margin: 0; font-size: 17px; overflow-wrap: anywhere; }

/* ---- Forms ------------------------------------------------------------------- */
.form { display: grid; gap: 18px; }
.field { display: grid; gap: 6px; }
.field label { font-size: 15px; font-weight: 500; }
.field__help { color: var(--text-2); font-size: 14px; }

.input {
  width: 100%;
  min-height: var(--tap);
  padding: 0 14px;
  background: var(--raised);
  color: var(--text);
  border: 1px solid var(--line-ui);
  border-radius: 10px;
  font: inherit;
  font-size: 16px; /* 16px stops iOS zooming into the field */
  transition: border-color 0.2s;
}
.input:hover { border-color: var(--text-2); }
.input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-color: var(--focus); }
.input[readonly] { color: var(--text-2); border-style: dashed; }
.input[aria-invalid="true"] { border-color: var(--danger); }

.check {
  display: inline-flex; align-items: center; gap: 12px;
  min-height: 44px;
  font-size: 15px; color: var(--text-2);
  cursor: pointer;
}
.check input { width: 22px; height: 22px; margin: 0; accent-color: var(--accent); }

/* Always in the page so screen readers announce it when text arrives. Collapses when empty. */
.msg {
  padding: 12px 14px;
  border: 1px solid var(--danger);
  border-radius: 10px;
  background: color-mix(in srgb, var(--danger) 10%, var(--surface));
  color: var(--text);
  font-size: 15px;
}
.msg:empty { padding: 0; border: 0; margin: -9px 0; background: none; }
.msg--ok { border-color: var(--success); background: color-mix(in srgb, var(--success) 10%, var(--surface)); }

/* ---- Buttons ------------------------------------------------------------------ */
.btn {
  position: relative; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 22px;
  background: var(--accent);
  color: var(--on-accent);
  border: 1px solid var(--accent);
  border-radius: 10px;
  font: 500 16px/1 var(--sans);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.2s var(--ease-out);
}
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn:active { transform: scale(0.98); }
.btn--block { width: 100%; }
.btn--quiet { background: transparent; color: var(--text); border-color: var(--line-ui); }
.btn--quiet:hover { background: var(--raised); border-color: var(--text-2); color: var(--text); }
.btn[disabled], .btn[aria-busy="true"] { opacity: 0.55; cursor: progress; pointer-events: none; }

/* A slow sheen across the main button. */
.btn:not(.btn--quiet)::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.28) 50%, transparent 65%);
  transform: translateX(-160%);
  animation: sheen 7s var(--ease-out) 1.2s infinite;
  pointer-events: none;
}
@keyframes sheen { 0%, 70% { transform: translateX(-160%); } 100% { transform: translateX(160%); } }

.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.card .actions .btn { margin-top: 0; }

/* ---- Site link ------------------------------------------------------------------ */
.site-link {
  display: inline-block;
  font: 300 clamp(26px, 7vw, 34px)/1.15 var(--display);
  color: var(--accent);
  text-decoration-thickness: 1px;
  overflow-wrap: anywhere;
}

/* ---- Dialog ----------------------------------------------------------------------- */
.dialog {
  width: min(440px, calc(100vw - 32px));
  padding: 24px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line-ui);
  border-radius: 16px;
}
.dialog::backdrop { background: rgba(5, 9, 7, 0.6); }
.dialog h2 { font: 400 28px/1.15 var(--display); margin-bottom: 8px; }
.dialog p { margin: 0 0 20px; color: var(--text-2); }
.dialog .field { margin: 0 0 16px; }
.dialog .msg { margin: 0 0 16px; }
.dialog .msg:empty { margin: 0; }

/* ---- Loading and notices ----------------------------------------------------------- */
.loading { color: var(--text-2); }
.notice {
  padding: 18px 20px;
  border: 1px solid var(--line-ui);
  border-radius: 14px;
  background: var(--surface);
}
.notice p { margin: 0; }
.notice p + p, .notice .btn { margin-top: 12px; }

/* ---- Arrival ------------------------------------------------------------------------ */
.rise { animation: rise 0.9s var(--ease-out) both; }
.rise:nth-child(2) { animation-delay: 0.08s; }
.rise:nth-child(3) { animation-delay: 0.16s; }
.rise:nth-child(4) { animation-delay: 0.24s; }
.rise:nth-child(5) { animation-delay: 0.32s; }
.head { animation: rise 0.9s var(--ease-out) both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.card p + .actions, .card .msg + .actions { margin-top: 16px; }
.card .actions + .msg { margin-top: 16px; }

/* ---- Requests (step 8.4) ------------------------------------------------------------ */
.textarea { min-height: 150px; padding: 12px 14px; line-height: 1.5; resize: vertical; }

.req-list { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.req-item {
  display: grid; gap: 6px;
  min-height: var(--tap);
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.2s, background 0.2s;
}
.req-item:hover { border-color: var(--line-ui); background: var(--raised); color: var(--text); }
.req-item__title { font-size: 17px; font-weight: 500; overflow-wrap: anywhere; }
.req-item__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; color: var(--text-2); font-size: 14px; }

.pill {
  display: inline-flex; align-items: center;
  min-height: 28px; padding: 0 12px;
  border: 1px solid var(--line-ui);
  border-radius: 999px;
  color: var(--text);
  font-size: 14px; font-weight: 500;
  white-space: nowrap;
}
.pill--active { border-color: var(--accent); color: var(--accent); }
.pill--good { border-color: var(--success); color: var(--success); }
.pill--ask { border-color: var(--brass); color: var(--text); background: color-mix(in srgb, var(--brass) 14%, var(--surface)); }
.pill--quiet { color: var(--text-2); }

.shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; margin: 0; padding: 0; list-style: none; }
.shot {
  position: relative; display: grid; align-content: start; gap: 6px;
  padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--raised);
  font-size: 13px; color: var(--text-2);
}
.shot img { display: block; width: 100%; height: 96px; object-fit: cover; border-radius: 6px; background: var(--bg); }
.shot a { display: block; line-height: 0; }
.shot__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shot .btn { min-height: 44px; padding: 0 12px; font-size: 14px; margin: 0; }

.thread { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.post { display: grid; gap: 6px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--raised); }
.post--me { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.post__who { color: var(--text-2); font-size: 14px; }
.post__who strong { color: var(--text); font-weight: 500; }
.post__body { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }

.notice--good { border-color: var(--success); }
.preview-box { display: grid; gap: 12px; }
.back { display: inline-flex; align-items: center; min-height: var(--tap); margin: -8px 0 4px; color: var(--text-2); }
.card h3, .stack > h2 { margin: 0; font: 500 17px/1.3 var(--sans); }
.stack > h2 { margin-top: 12px; }
.fileline { display: grid; gap: 10px; }
.input[type="file"] { padding: 10px 14px; height: auto; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.title-sm { font-size: clamp(30px, 8vw, 44px); line-height: 1.1; overflow-wrap: anywhere; }
.stack > section:not(.card) > h2 { margin-bottom: 12px; }
.card .shots, .card .thread { margin-top: 12px; }
.card .field + .msg, .card .msg + .field { margin-top: 0; }

/* ---- Plan and payments (step 8.3) ----------------------------------------------------- */
.textarea--short { min-height: 88px; }
.btn--small { min-height: 44px; padding: 0 14px; font-size: 15px; }
.card .btn--small { margin-top: 0; }

/* A calm line under a plan: overdue, or "you asked to pause". Never red. */
.note {
  padding: 12px 14px;
  border: 1px solid var(--line-ui);
  border-radius: 10px;
  background: var(--raised);
  font-size: 15px;
}
.card p.note { margin-top: 14px; }
.card .facts { margin-top: 14px; }

.included { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.included__label { color: var(--text-2); font-size: 14px; }

.pay-list { display: grid; margin: 0; padding: 0; list-style: none; }
.pay-row {
  display: grid; gap: 4px 16px;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "main receipt" "meta receipt";
  align-items: center;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}
.pay-row:first-child { border-top: 0; padding-top: 0; }
.pay-row__main { grid-area: main; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; }
.pay-row__amount { font-size: 19px; font-weight: 500; }
.pay-row__date { color: var(--text-2); }
.nowrap { white-space: nowrap; }
.col { display: grid; gap: 16px; align-content: start; }
.pay-row__meta { grid-area: meta; color: var(--text-2); font-size: 14px; }
.pay-row__receipt {
  grid-area: receipt;
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--tap); padding: 0 6px;
}

.copyline {
  display: grid; gap: 6px 12px;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  margin-top: 14px; padding: 12px 14px;
  border: 1px dashed var(--line-ui); border-radius: 10px; background: var(--raised);
}
.card .copyline { margin-top: 14px; }
.card p + .copyline { margin-top: 16px; }
.copyline__label { grid-column: 1 / -1; color: var(--text-2); font-size: 14px; }
.copyline__value { font: 500 16px/1.3 var(--sans); overflow-wrap: anywhere; }

/* ---- Receipt ----------------------------------------------------------------------------- */
.receipt__title { margin: 0 0 18px; font: 300 clamp(36px, 10vw, 52px)/1.05 var(--display); }
.facts--receipt dd { font-size: 18px; }
.receipt + .btn { margin-top: 16px; }

@media print {
  :root { color-scheme: light; }
  html, body { background: #fff !important; color: #000 !important; }
  body::before, body::after, .head, .foot, .skip, .no-print { display: none !important; }
  .page, .page--narrow { max-width: none; padding: 0; }
  .rise { animation: none !important; }
  .card.receipt { border: 1px solid #000; background: #fff; border-radius: 0; padding: 24px; break-inside: avoid; }
  .receipt__title { color: #000; }
  .facts dt { color: #333; }
  .facts dd { color: #000; }
}
/* Four or five links do not fit beside the name on a phone, so the menu drops to its own line. */
@media (max-width: 560px) {
  .head { flex-wrap: wrap; gap: 0 16px; padding-top: 4px; padding-bottom: 4px; }
  .nav { flex: 1 1 100%; margin: 0 -12px; overflow-x: auto; }
}
.card .fileline { margin-top: 18px; }
.shots-host:not(:empty) { margin-top: 18px; }
/* The text under a fact list leaves room before the buttons that follow it. */
.card .facts + .actions { margin-top: 18px; }
/* Cards in a row keep their own height instead of stretching to the tallest one. */
.grid--two { align-items: start; }
/* The picture picker's own button, styled like the rest. */
.input[type="file"]::file-selector-button {
  min-height: 36px; margin-right: 12px; padding: 0 14px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line-ui); border-radius: 8px;
  font: inherit; font-size: 15px; cursor: pointer;
}
.card p.card__label:not(:first-child) { margin-top: 18px; }
