/* Hlanganisa Collective: toasts and modals for happy and unhappy paths.
   Square corners, hairlines, no shadows, one accent. Rules: DESIGN.md.
   Behaviour lives in /js/notify.js. Light only, like the rest of the site. */

:root {
  --hl-green: #1C4532;
  --hl-green-tint: #EEF2ED;
  --hl-error: #8A2A1F;
  --hl-error-tint: #F5E3DF;
  --hl-amber: #7A5A12;
  --hl-amber-tint: #F6EFD9;
  --hl-ink: #10130F;
  --hl-ink-soft: #4A4F48;
  --hl-sand: #F1EBDD;
  --hl-line: #CFCCC0;
  --hl-white: #FFFFFF;
  --hl-ease: cubic-bezier(0.16, 1, 0.3, 1);
}

/* Type colours: --c is the strong colour, --t is its quiet tint. */
.hl-success { --c: var(--hl-green); --t: var(--hl-green-tint); }
.hl-error   { --c: var(--hl-error); --t: var(--hl-error-tint); }
.hl-warning { --c: var(--hl-amber); --t: var(--hl-amber-tint); }
.hl-info    { --c: var(--hl-ink);   --t: var(--hl-sand); }

/* ---- Toasts ---- */
.hl-toasts {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 2147483000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(380px, calc(100vw - 32px));
  margin: 0;
  padding: 0;
  pointer-events: none;
}
.hl-toast {
  position: relative;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 14px 12px 14px 14px;
  background: var(--hl-white);
  border: 1px solid var(--hl-line);
  border-top: 2px solid var(--c);
  color: var(--hl-ink);
  font-family: 'Instrument Sans', system-ui, sans-serif;
  pointer-events: auto;
}
.hl-ico {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  background: var(--t);
  color: var(--c);
  flex: none;
}
.hl-ico svg, .hl-x svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.hl-ico svg { width: 20px; height: 20px; }
.hl-t-title { margin: 0; font-weight: 600; font-size: 0.95rem; line-height: 1.35; text-wrap: balance; }
.hl-t-msg { margin: 2px 0 0; font-size: 0.88rem; line-height: 1.5; color: var(--hl-ink-soft); text-wrap: pretty; }
.hl-t-act {
  margin: 8px 0 0;
  padding: 0;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--c);
  background: none;
  border: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.hl-x {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  color: var(--hl-ink-soft);
  background: none;
  border: 0;
  cursor: pointer;
}
.hl-x:hover { color: var(--hl-ink); background: var(--hl-sand); }
.hl-x svg { width: 16px; height: 16px; }
.hl-toast :focus-visible, .hl-modal :focus-visible { outline: 2px solid var(--hl-green); outline-offset: 2px; }

/* Countdown for toasts that dismiss themselves, so the wait is never silent. */
.hl-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--c); opacity: 0.35; transform-origin: left; }

/* ---- Modals ---- */
.hl-modal {
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  margin: auto;
  padding: 0;
  overflow: auto;
  color: var(--hl-ink);
  background: var(--hl-white);
  border: 1px solid var(--hl-line);
  border-top: 3px solid var(--c);
  border-radius: 0;
  font-family: 'Instrument Sans', system-ui, sans-serif;
}
.hl-modal::backdrop { background: rgba(16, 19, 15, 0.5); }
.hl-m-body { padding: 2.2rem 2.2rem 2rem; }
.hl-m-icon { display: grid; place-items: center; width: 52px; height: 52px; background: var(--t); color: var(--c); margin-bottom: 1.4rem; }
.hl-m-icon svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.hl-m-eyebrow { margin: 0 0 0.6rem; font-size: 0.68rem; font-weight: 600; letter-spacing: 0.22em; text-transform: uppercase; color: var(--c); text-wrap: balance; }
.hl-modal h2 { margin: 0 0 0.8rem; padding: 0; border: 0; font-family: 'Fraunces', serif; font-weight: 300; font-size: clamp(1.6rem, 4vw, 2rem); line-height: 1.12; letter-spacing: -0.015em; text-wrap: balance; }
.hl-m-msg { margin: 0; font-size: 1rem; line-height: 1.6; color: var(--hl-ink-soft); text-wrap: pretty; }
.hl-m-steps { margin: 1.4rem 0 0; padding: 0; list-style: none; counter-reset: s; display: grid; gap: 0.7rem; }
.hl-m-steps li { counter-increment: s; display: grid; grid-template-columns: 1.6rem minmax(0, 1fr); gap: 0.6rem; font-size: 0.95rem; line-height: 1.5; color: var(--hl-ink-soft); text-wrap: pretty; }
.hl-m-steps li::before { content: counter(s); font-weight: 700; font-size: 0.8rem; color: var(--c); padding-top: 0.12rem; }
.hl-m-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.8rem 1.4rem; margin-top: 1.8rem; }
.hl-m-actions .btn, .hl-m-btn {
  font: inherit; font-weight: 600; letter-spacing: 0.02em; color: var(--hl-white); background: var(--hl-green);
  border: 1px solid var(--hl-green); padding: 0.85rem 1.4rem; border-radius: 0; cursor: pointer; text-decoration: none; display: inline-block;
}
.hl-m-actions .btn:hover, .hl-m-btn:hover { background: #2E6148; border-color: #2E6148; color: var(--hl-white); }
.hl-error .hl-m-btn { background: var(--hl-error); border-color: var(--hl-error); }
.hl-error .hl-m-btn:hover { background: #6E2018; border-color: #6E2018; }
.hl-m-link { font: inherit; font-weight: 600; color: var(--hl-green); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.hl-m-close { position: absolute; top: 10px; right: 10px; display: grid; place-items: center; width: 36px; height: 36px; padding: 0; color: var(--hl-ink-soft); background: none; border: 0; cursor: pointer; }
.hl-m-close:hover { color: var(--hl-ink); background: var(--hl-sand); }
.hl-m-close svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
body.hl-lock { overflow: hidden; }

/* Phones: toasts sit across the bottom, modals use the full gutter. */
@media (max-width: 520px) {
  .hl-toasts { right: 16px; left: 16px; bottom: 16px; width: auto; }
  .hl-m-body { padding: 1.8rem 1.4rem 1.6rem; }
  .hl-m-actions { flex-direction: column; align-items: stretch; }
  .hl-m-actions .btn, .hl-m-btn { text-align: center; }
  .hl-m-link { text-align: center; padding: 0.4rem 0; }
}

/* Motion: only for visitors who have not asked for less. */
@media (prefers-reduced-motion: no-preference) {
  .hl-toast { animation: hl-in 0.5s var(--hl-ease) both; }
  .hl-toast.hl-out { animation: hl-out 0.25s ease forwards; }
  .hl-bar { animation: hl-run var(--hl-dur, 6000ms) linear forwards; }
  .hl-toast:hover .hl-bar, .hl-toast:focus-within .hl-bar { animation-play-state: paused; }
  /* backwards, not both: a held transform would trap the fixed toast region inside the dialog. */
  .hl-modal[open] { animation: hl-pop 0.45s var(--hl-ease) backwards; }
  .hl-modal[open]::backdrop { animation: hl-fade 0.3s ease backwards; }
  .hl-success .hl-m-icon circle, .hl-success .hl-ico circle { stroke-dasharray: 1; stroke-dashoffset: 1; animation: hl-draw 0.5s ease 0.1s forwards; }
  .hl-success .hl-m-icon .tick, .hl-success .hl-ico .tick { stroke-dasharray: 1; stroke-dashoffset: 1; animation: hl-draw 0.4s ease 0.45s forwards; }
  .hl-error .hl-m-icon { animation: hl-nudge 0.5s ease 0.15s both; }
}
@keyframes hl-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes hl-out { to { opacity: 0; transform: translateY(6px); } }
@keyframes hl-run { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes hl-pop { from { opacity: 0; transform: translateY(18px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes hl-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes hl-draw { to { stroke-dashoffset: 0; } }
@keyframes hl-nudge { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 60% { transform: translateX(4px); } }
