/* MDIL Meetings — web application styles.
   Builds on MDIL design tokens vendored from the `mdil-design` repo
   (colors/typography/spacing/fonts). The DS type scale is slide-sized
   (96–104px); this file keeps the DS
   font families, weights and letterforms but defines a web-appropriate scale
   and the app's chrome/forms/cards. Dark-by-construction, per the brand. */
@import url("tokens/fonts.css");
@import url("tokens/colors.css");
@import url("tokens/typography.css");
@import url("tokens/spacing.css");

/* test */
:root {
  /* Web-appropriate type scale (overrides the slide-sized DS scale). */
  --app-h1: 2rem;
  --app-h2: 1.3rem;
  --app-lede: 1.18rem;
  --app-body: 1rem;
  --app-meta: 0.78rem;
  --app-maxw: 1320px;

  /* The container is wide; running text is not. Prose and form fields sit on
     their own measure inside it, or a paragraph runs 1320px and a name field
     becomes a 1300px slot. */
  --app-measure: 720px;
  --app-radius: var(--r-lg);
  --focus-ring: 0 0 0 3px rgb(161 0 255 / 35%);

  /* Back-compat aliases for the pre-brand placeholder tokens still referenced
     by a few inline styles (e.g. legal "last updated" lines). */
  --muted: var(--text-label);
  --line: var(--hair);

  /* WCAG 2.1 AA (axe-core color-contrast): the MDIL ink ramp is tuned for
     slide-medium labels; --ink-mute (.40 → 3.2:1) and --ink-dim (.26 → 2:1) fall
     below 4.5:1 as small web text. Lift the label step up the SAME lavender ramp
     to AA on --bg-deep (~5:1); readable-text uses of --ink-dim are repointed to
     --ink-mute below. Brand hue unchanged (mdil-design ramp preserved). */
  --ink-mute: rgb(239 227 248 / 55%);

  /* The chrome is dark and the content is light (see .lightbody), so the UA
     is told per-region rather than once for the document — otherwise native
     controls inside the light body render as dark widgets on lilac. */
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);

  /* Faint purple radial glows over black — the brand's only "texture". */
  background-image: var(--glow-tr), var(--glow-bl);
  background-attachment: fixed;
  color: var(--text-body);
  font-family: var(--sans);
  font-size: var(--app-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-flow: column;
  justify-content: stretch;

  > main {
    flex-grow: 100;
  }
}

h1,
h2,
h3 {
  font-family: var(--head);
  color: var(--text-heading);
  letter-spacing: var(--ls-head);
  line-height: 1.12;
  font-weight: var(--fw-head);
}

h1 {
  font-size: var(--app-h1);
  margin: 0 0 0.6rem;
}

h2 {
  font-size: var(--app-h2);
  margin: 1.8rem 0 0.6rem;
  font-weight: var(--fw-semibold);
}

h3 {
  font-size: 1.05rem;
  margin: 1.2rem 0 0.4rem;
  font-weight: var(--fw-semibold);
}

p {
  margin: 0.7rem 0;
}

strong {
  color: var(--ink);
  font-weight: var(--fw-semibold);
}

em {
  color: var(--brand-2);
  font-style: normal;
}

a {
  color: var(--brand-2);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Mono kicker — the house label style (uppercase, tracked, purple bar). */
.kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--mono);
  font-size: var(--fs-kicker);
  font-size: clamp(0.72rem, 1.4vw, 0.82rem);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: var(--text-label);
  margin: 0 0 1rem;

  &::before {
    content: "";
    width: 34px;
    height: 2px;
    background: var(--brand);
  }
}

.lede {
  font-size: var(--app-lede);
  line-height: var(--lh-lede);
  color: var(--text-caption);
}

/* ── Layout ─────────────────────────────────────────── */
.container {
  max-width: var(--app-maxw);
  margin: 0 auto;
  padding: 0 1.2rem;
}

/* ── Head: header + hero as one surface ─────────────
   The dark ground and the brand glow live here, not on the header and not on
   the hero, so the two stack without a seam between them and a page with no
   hero still gets a proper header slab. */

.head {
  background: var(--bg-deep);
  background-image: var(--glow-tr), var(--glow-bl);
  border-bottom: 1px solid var(--hair);
}

/* ── Header chrome ──────────────────────────────────── */
header.site {
  /* Transparent: .head paints behind it. */
  background: transparent;

  .container {
    /* The taller mark leaves less room for a signed-in nav (six items), so
       the row wraps rather than pushing the page into a horizontal scroll. */
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem 1rem;
    min-height: 88px;
    padding-block: 0.7rem;
  }

  .brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;

    /* 52px tall, served as a 2x raster (222x104) — see the header markup. */
    img {
      height: 52px;
      width: auto;
      display: block;
    }
  }

  nav {
    margin-left: auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.7rem 1.4rem;

    a,
    button {
      font-family: var(--mono);
      font-size: var(--app-meta);
      letter-spacing: 0.08em;
      text-transform: uppercase;
      color: var(--text-label);
      margin-top: 0;
      background: none;
      border: 0;
      padding: 0;
      cursor: pointer;

      &:hover {
        color: var(--ink);
        text-decoration: none;
      }
    }

    /* SEC-11: sign-out is a POST form; make its button read as a nav link. */
    .signout {
      display: flex;
      margin: 0;
    }
  }
}

/* ── Hero ───────────────────────────────────────────
   The mdil.ai page order: dark header, dark hero, light body, dark footer.
   Pages opt in by filling the `hero` block in site_base.html; a page without
   one simply has its light content start under the header. */

.hero {
  /* Ground and glow come from .head, which wraps this and the header. */
  padding: 3.4rem 0 4.4rem;
  text-align: center;
  min-height: 50vh;
  display: flex;
  align-items: center;
  align-content: center;
  justify-content: center;

  .container {
    max-width: 760px;
  }

  h1 {
    font-size: clamp(2.1rem, 5.6vw, 3.2rem);
    font-weight: var(--fw-title);
    letter-spacing: var(--ls-title);
    margin: 0.9rem 0 0;
  }

  .lede {
    max-width: 32em;
    margin: 1.1rem auto 0;
  }
}

/* The hero label is the bare tracked mono of mdil.ai's hero — the purple bar
   belongs to the section kickers further down the page, not to this one. */

.hero-kicker {
  font-family: var(--mono);
  font-size: clamp(0.72rem, 1.4vw, 0.81rem);
  letter-spacing: var(--ls-kicker);
  text-transform: uppercase;
  color: var(--text-label);
  margin: 0;
}

.hero-note {
  max-width: 38em;
  margin: 1.5rem auto 0;
  color: var(--text-caption);
}

.hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  justify-content: center;
  margin-top: 1.9rem;

  /* .btn carries margin-top for prose flow; in a gap'd row it is a stray step. */
  .btn {
    margin-top: 0;
  }
}

/* ── Main ───────────────────────────────────────────── */
main.site {
  padding: 3rem 0 4rem;
  min-height: 50vh;

  /* The container is 1320px so grids and slot rows can use it; prose must not.
     Cards opt out — they are already narrow, and a measure inside them would
     be a second, pointless cap. */

  p:not(.card p),
  ul:not(.card ul),
  ol:not(.card ol) {
    max-width: var(--app-measure);
  }

  /* main's padding already supplies the first heading's leading margin. */
  .container > :first-child {
    margin-top: 0;
  }

  /* In-page jump targets clear the top of the light body. */
  [id] {
    scroll-margin-top: 1.5rem;
  }
}

/* ── Light body ─────────────────────────────────────
   mdil.ai puts its content on lilac between dark chrome. This does the same
   by flipping the token layer once, rather than restyling each component.

   Two traps, both load-bearing:

   1. Custom properties inherit as COMPUTED values — `--text-heading: var(--ink)`
      resolved to white on :root, and re-declaring `--ink` here would not reach
      it. The semantic aliases have to be re-declared alongside the ramp.
   2. `color` likewise inherits as a computed value, not as the variable, so
      the body's ink has to be re-read here.

   The label step is .60, not the .52 the event page used: on --lilac-bg that
   is 4.83:1 where .52 is 3.72:1, and --text-label is small text (nav, footer,
   kickers, slot captions). Same AA rule that lifted --ink-mute on the dark
   side; the ramp's hue is untouched. */

.lightbody {
  background: var(--lilac-bg);
  color: var(--ink-soft);

  /* Native controls (checkboxes, radios, scrollbars) follow the region. */
  color-scheme: light;

  /* Surfaces: cards go white on lilac, wells barely off it. */
  --bg: var(--lilac-bg);
  --bg-deep: #e9dff1;
  --bg-card: #ffffff;
  --bg-card-2: rgb(22 9 31 / 5%);
  --bg-well: rgb(22 9 31 / 3%);

  /* Ink — the violet-black mdil.ai writes with, on the same five steps. */
  --ink: #16091f;
  --ink-soft: rgb(22 9 31 / 80%);
  --ink-faint: rgb(22 9 31 / 68%);
  --ink-mute: rgb(22 9 31 / 60%);
  --ink-dim: rgb(22 9 31 / 42%);

  /* The lighter purple exists to carry on black. On lilac the brand itself
     carries — 4.5:1 — so links, em and kicker bars go to it. */
  --brand-2: var(--brand);

  /* Crimson at full strength: the dimmed pair reads pink on a light ground. */
  --accent-2: #b4232e;
  --accent-dim: var(--accent);

  /* Every `-2` token means "on dark" by definition, so each pair inverts:
     dark ink on a tint lifted off white, not pale ink on a dark one. */
  --amber-2: #8a5200;
  --amber-soft: rgb(217 138 43 / 13%);
  --amber-line: rgb(154 91 0 / 34%);
  --success-2: #16613f;
  --success-soft: rgb(30 138 85 / 8%);
  --success-line: rgb(30 138 85 / 32%);
  --info: #4b63c8;
  --info-2: #2e3f8f;
  --info-soft: rgb(75 99 200 / 7%);
  --info-line: rgb(75 99 200 / 26%);

  /* Hairlines drawn out of the ink rather than out of white. */
  --hair: rgb(22 9 31 / 13%);
  --hair-2: rgb(22 9 31 / 8.5%);

  /* Trap 1: the alias layer, re-resolved against the ramp above. */
  --surface-page: var(--bg);
  --surface-card: var(--bg-card);
  --surface-deep: var(--bg-deep);
  --text-heading: var(--ink);
  --text-body: var(--ink-soft);
  --text-caption: var(--ink-faint);
  --text-label: var(--ink-mute);
  --line-default: var(--hair);
  --line-subtle: var(--hair-2);
  --line-trust: var(--accent-dim);
  --muted: var(--text-label);
  --line: var(--hair);
}

/* ── Footer chrome ──────────────────────────────────── */
footer.site {
  border-top: 1px solid var(--hair);
  background: var(--bg-deep);

  .container {
    padding-top: 1.5rem;
    padding-bottom: 2.2rem;
  }

  nav {
    display: flex;
    flex-wrap: wrap;
    gap: 1.1rem;
    margin-bottom: 0.8rem;

    a {
      font-family: var(--mono);
      font-size: var(--app-meta);
      letter-spacing: 0.06em;
      color: var(--text-label);

      &:hover {
        color: var(--ink);
        text-decoration: none;
      }
    }
  }

  .pagemark {
    font-family: var(--mono);
    font-size: var(--app-meta);
    letter-spacing: 0.1em;
    color: var(--ink-mute); /* readable footer text (was --ink-dim, ~2:1) */
  }
}

/* Small print under a form — was an inline font-size/colour pair. */
.finemark {
  font-size: 0.85rem;
  color: var(--text-label);
}

/* ── Cards ──────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--hair);
  border-radius: var(--app-radius);
  padding: 1.2rem 1.3rem;
}

.cards {
  display: grid;
  gap: var(--sp-4);

  @media (width >= 640px) {
    &.cols3 {
      grid-template-columns: repeat(3, 1fr);
    }
  }
}

/* ── Forms ──────────────────────────────────────────── */
fieldset {
  border: 0;
  padding: 0;
  margin: 0;
}

label {
  display: block;
  margin: 0.9rem 0 0.3rem;
  font-weight: var(--fw-semibold);
  color: var(--ink-soft);
}

input:not([type="radio"], [type="checkbox"], [type="submit"], [type="cancel"]),
textarea,
select {
  display: block;
  width: 100%;
  max-width: var(--app-measure);
  padding: 0.6rem 0.7rem;
  background: var(--bg-well);
  border: 1px solid var(--hair);
  border-radius: var(--r-sm);
  color: var(--ink);
  font: inherit;

  &::placeholder {
    color: var(--ink-mute); /* informative placeholder → AA (was --ink-dim) */
  }

  &:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: var(--focus-ring);
  }
}

button,
.btn {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.65rem 1.3rem;
  border: 0;
  border-radius: var(--r-sm);
  background: var(--brand);
  color: #ffffff;
  font-family: var(--head);
  font-weight: var(--fw-semibold);
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;

  &:hover {
    background: var(--brand-2);
    text-decoration: none;
  }

  &:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
  }
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--hair);
  color: var(--ink);

  &:hover {
    background: var(--bg-card-2);
    border-color: var(--brand);
  }
}

/* "Assign to": a one-line checklist of people, each box inside its label.
   It undoes the form label's block and 600 — a name here is a choice to
   tick, not a field heading. */

.assign {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 1.1rem;

  .assign-label {
    font-family: var(--mono);
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-label);
  }

  label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
    font-weight: var(--fw-body);
    color: var(--ink-soft);
    cursor: pointer;
  }

  input {
    margin: 0;
    accent-color: var(--brand);
  }
}

.errorlist {
  color: var(--accent-2);
  list-style: none;
  padding: 0;
  margin: 0.3rem 0;
  font-size: 0.9rem;
}

/* ── Messages / banners ─────────────────────────────── */
.msg,
.banner {
  padding: 0.75rem 1rem;
  border-radius: var(--r-md);
  margin: 0.7rem 0;
  border: 1px solid var(--hair);
  background: var(--bg-card);

  &.success {
    background: var(--success-soft);
    border-color: var(--success-line);
    color: var(--success-2);
  }

  &.error {
    background: var(--accent-soft);
    border-color: var(--accent-dim);
    color: var(--accent-2);
  }
}

.msg.warning,
.draft {
  background: var(--amber-soft);
  border: 1px solid var(--amber-line);
  color: var(--amber-2);
  border-radius: var(--r-md);
  padding: 0.75rem 1rem;
}

/* ── Legal / long-form reading ──────────────────────── */
.legal {
  max-width: 740px;

  h2 {
    font-size: 1.15rem;
  }

  p,
  li {
    color: var(--text-caption);
  }
}

/* ── Slots (booking) ────────────────────────────────── */
.slot {
  border: 1px solid var(--hair);
  border-radius: var(--r-sm);
  padding: 0.65rem 0.95rem;
  margin: 0.45rem 0;
  background: var(--bg-card);
}

/* Date headings above each row of times. They are <h2> now — the group's
   context header — so they take the h2 scale and only the rhythm is local. */

.day {
  margin: 1.8rem 0 0.7rem;
  color: var(--ink-soft);
}

.slots {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;

  /* One line, one time — the date is the group's h2, so the button says only
     what distinguishes it from its neighbours. */

  .slotbtn {
    border: 1px solid var(--hair);
    border-radius: var(--r-sm);
    padding: 0.55rem 0.9rem;
    background: var(--bg-card);

    /* It drops the button's purple fill, so it must drop the white label the
       base rule pairs with that fill — on a light --bg-card it vanishes. */
    color: var(--ink);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 8.5rem;
    line-height: 1.25;
    font-family: var(--mono);

    /* It is a <label>, so it inherited the form-label 600 — and IBM Plex Mono
       ships 400 and 500 only, so 600 was SYNTHESISED and read as smeared. A
       time is data, not emphasis. */
    font-weight: var(--fw-body);
    font-variant-numeric: tabular-nums;

    input {
      position: absolute;
      opacity: 0;
      pointer-events: none;
    }

    &:hover {
      border-color: var(--brand);
      background: var(--bg-card-2);
    }

    &:has(input:checked) {
      border-color: var(--brand);
      background: var(--brand-dim);
      box-shadow: 0 0 0 1px var(--brand) inset;
    }

    &:has(input:focus-visible) {
      box-shadow: var(--focus-ring);
    }
  }
}
