/* City of Centennial AI Hub - base styles.
   Palette + accessible pairings from the 2024 Comms Style Guide (see BUILD.md).
   Contrast is designed to pass WCAG 2.1 AA by staying inside those pairings. */

:root {
  color-scheme: light dark;

  --mountain-blue: #002E6D; /* primary dark / headings / hero */
  --medium-blue:   #0055B8; /* links, buttons */
  --sky-blue:      #3D7CC9; /* secondary accents */
  --light-blue:    #95D4E9; /* tints, backgrounds */
  --sunrise:       #FFD600; /* highlight, sparingly */
  --white:         #FFFFFF;
  --ink:           #14243d;

  /* Per-org brand colors. /theme.php overrides these per tenant; these defaults
     are the City of Centennial palette. */
  --brand-primary:   var(--mountain-blue); /* masthead band */
  --brand-accent:    var(--sunrise);       /* highlight / sun mark */
  --brand-link:      var(--medium-blue);   /* links, buttons */
  --brand-secondary: var(--sky-blue);      /* secondary accents */
  --brand-tint:      var(--light-blue);    /* tints, backgrounds */

  --bg:      #ffffff;
  --surface: #f4f7fb;
  --border:  #d5deea;
  --text:    var(--ink);
  --heading: var(--brand-primary);
  --link:    var(--brand-link);
  --focus:   #b8007a; /* high-contrast focus ring, distinct from brand blues */

  /* Muted/hint text: deliberately NOT tied to --brand-secondary. That color
     is admin-customizable per org with no contrast validation on save, and
     two of the three built-in presets fail WCAG 1.4.3 at this text's size
     (Centennial 4.26:1, Forest 3.24:1) -- a fixed, verified value avoids
     that regardless of what an org picks. 5.42:1 against --bg/--surface. */
  --muted-text: #5A6B85;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:      #0d1626;
    --surface: #152135;
    --border:  #2a3a54;
    --text:    #e8eef7;
    --heading: var(--light-blue);
    --link:    #8fc0f0;
    --focus:   #ffd600;
    --muted-text: #A9B8CE; /* 9.00:1 against the dark bg above */
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Figtree", "Proxima Nova", Arial, sans-serif;
  line-height: 1.6;
}

h1, h2, h3 { color: var(--heading); line-height: 1.2; }
h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); margin: 0 0 .5rem; }
h2 { font-size: 1.35rem; margin: 0 0 .5rem; }
h3 { font-size: 1.1rem; margin: 0 0 .35rem; }

a { color: var(--link); }
a:hover { text-decoration: underline; }

/* Visible focus for every interactive element (keyboard-first). */
a:focus-visible,
button:focus-visible,
.btn:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 3px;
}

/* --focus (#b8007a) is only 2.06:1 against a dark --brand-primary masthead
   band -- fails WCAG 1.4.11 (needs 3:1). White clears 13:1+ against every
   built-in preset's primary (all deliberately dark, per the branding form's
   own guidance), so the masthead gets its own focus treatment; the subtle
   dark shadow keeps it visible if a future org's primary is ever light. */
.masthead a:focus-visible,
.masthead button:focus-visible,
.masthead .btn:focus-visible {
  outline-color: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .4);
}

/* Skip link: hidden until focused. */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--brand-primary);
  color: var(--white);
  padding: .6rem 1rem;
  z-index: 100;
}
.skip-link:focus {
  left: .5rem;
  top: .5rem;
}

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

.wrap { padding: 1.5rem .75rem; }

/* Long-form text (a library entry's body, eventual policy prose) reads badly
   at full width on a wide monitor -- cap just that content, not the page
   shell around it. */
.prose { max-width: 60rem; }

/* Masthead */
.masthead {
  background: var(--brand-primary);
  color: var(--white);
}
.masthead__inner {
  padding: .85rem .75rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  color: var(--white);
  text-decoration: none;
  font-size: 1.15rem;
}
.brand:hover { text-decoration: none; }
.brand__text strong { color: var(--brand-accent); font-weight: 800; }
.brand__sun {
  width: 1.1rem; height: 1.1rem; border-radius: 50%;
  background: var(--brand-accent);
  box-shadow: 0 0 0 3px rgba(255, 214, 0, .25);
  flex: 0 0 auto;
}
.brand__logo { max-height: 3rem; width: auto; display: block; }
.masthead__nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}
.masthead__sitenav {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.masthead__sitenav a {
  color: var(--white);
  font-weight: 600;
  text-decoration: none;
}
.masthead__sitenav a:hover { text-decoration: underline; }
.masthead__who { color: var(--brand-tint); font-size: .9rem; }

/* Avatars: Microsoft photo or an initials circle */
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 auto;
  vertical-align: middle;
}
.avatar--initials {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-secondary);
  color: #fff;
  font-weight: 700;
  font-size: .8rem;
  line-height: 1;
}
.masthead .avatar { box-shadow: 0 0 0 2px rgba(255,255,255,.35); }
.avatar--lg { width: 64px; height: 64px; }
.avatar--lg.avatar--initials { font-size: 1.5rem; }
.you-row { display: flex; gap: 1rem; align-items: center; }
.you-row .kv { margin: 0; }

/* Buttons */
.btn {
  display: inline-block;
  padding: .6rem 1.1rem;
  border-radius: .4rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  border: 2px solid transparent;
}
.btn--primary { background: var(--brand-link); color: var(--white); }
.btn--primary:hover { background: #00478f; text-decoration: none; }
.btn--ghost { background: transparent; border-color: currentColor; color: var(--white); }
.masthead .btn--ghost { color: var(--white); }
.wrap .btn--ghost { color: var(--link); }
.wrap .btn--ghost:hover { background: var(--surface); text-decoration: none; }

/* Hero + content */
.hero { padding: 1rem 0 1.5rem; }
.lead { font-size: 1.15rem; }
.muted { color: var(--muted-text); }

.tiers {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  margin-top: 1rem;
}
.tier, .card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: .6rem;
  padding: 1.1rem 1.25rem;
}
.card { margin: 1.25rem 0; }

/* Entry detail: main content + a like sidebar. flex-wrap stacks the sidebar
   below main on narrow viewports instead of forcing horizontal scroll. */
.entry-layout { display: flex; gap: 1.5rem; flex-wrap: wrap; align-items: flex-start; }
.entry-layout__main { flex: 1 1 60%; min-width: 0; }
.entry-layout__side { flex: 0 0 200px; }

/* Key/value lists */
.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: .4rem 1rem;
  margin: .5rem 0 0;
}
.kv dt { font-weight: 700; }
.kv dd { margin: 0; }
.mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; word-break: break-all; }

/* Tags */
.tag {
  display: inline-block;
  padding: .1rem .5rem;
  border-radius: .35rem;
  background: var(--brand-tint);
  color: var(--brand-primary);
  font-weight: 700;
  font-size: .85rem;
  margin: 0 .25rem .25rem 0;
}
.tag--yes { background: #0a7d33; color: #fff; }
.tag--no  { background: #8a1c1c; color: #fff; }

/* Footer */
.foot {
  border-top: 1px solid var(--border);
  margin-top: 2rem;
  color: var(--muted-text);
  font-size: .9rem;
}
.foot .wrap { padding-top: 1rem; padding-bottom: 1rem; }

/* Alerts */
.alert {
  padding: .75rem 1rem;
  border-radius: .4rem;
  border: 1px solid transparent;
  margin: 1rem 0;
}
.alert--ok   { background: #e5f4ea; border-color: #0a7d33; color: #0a4a1f; }
.alert--err  { background: #fbe7e7; border-color: #8a1c1c; color: #6a1010; }
.alert--info { background: #e7f0fb; border-color: var(--brand-link); color: #0a3a70; }
@media (prefers-color-scheme: dark) {
  .alert--ok   { background: #10331c; color: #b6e6c4; }
  .alert--err  { background: #3a1414; color: #f0b8b8; }
  .alert--info { background: #10233d; color: #b9d6f5; }
}

/* Forms */
.form { margin-top: .5rem; }
.form--narrow { max-width: 22rem; }
.field { margin: 0 0 1rem; }
.field label { display: block; font-weight: 700; margin-bottom: .3rem; }
.field input[type="text"],
.field input[type="password"],
.field select,
.field textarea {
  width: 100%;
  padding: .55rem .6rem;
  border: 1px solid var(--border);
  border-radius: .4rem;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.field input:focus-visible,
.field select:focus-visible,
.field textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
}
.field textarea { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; }
.hint { margin: .3rem 0 0; font-size: .9rem; color: var(--muted-text); }

.field--color input[type="color"] {
  width: 3.5rem; height: 2.4rem; padding: 2px;
  border: 1px solid var(--border); border-radius: .4rem; background: var(--bg);
  cursor: pointer;
}
.checkbox { display: inline-flex; gap: .45rem; align-items: center; font-weight: 400; margin: .3rem 0; }
.logo-preview {
  max-height: 3.5rem; width: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: .4rem; padding: .35rem;
}

.advanced { margin: .5rem 0 1.25rem; }
.advanced summary { cursor: pointer; font-weight: 700; color: var(--link); padding: .25rem 0; }
.advanced[open] { padding-top: .5rem; }

.likes-detail { margin-top: .5rem; font-size: .9rem; }
.likes-detail summary { cursor: pointer; color: var(--link); padding: .25rem 0; }
.likes-detail[open] summary { margin-bottom: .25rem; }
.likes-detail .hint { margin: 0 0 .25rem; }
/* Capped height regardless of like count -- a popular entry with hundreds of
   likes scrolls inside this box instead of stretching the sidebar. */
.likes-detail__list {
  max-height: 10rem;
  overflow-y: auto;
  margin: 0;
  padding: .25rem .5rem;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: .4rem;
  background: var(--bg);
}
.likes-detail__list li { padding: .15rem 0; }

/* Ordered step lists */
.steps { margin: .5rem 0; padding-left: 1.25rem; }
.steps li { margin: .35rem 0; }

/* Copyable value box */
.copybox {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand-link);
  border-radius: .4rem;
  padding: .6rem .75rem;
  margin: .75rem 0;
}
.copybox__label {
  font-weight: 700;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--muted-text);
  flex: 0 0 100%;
}
.copybox__val {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  word-break: break-all;
  user-select: all;
}
.copybox__btn {
  font: inherit;
  font-size: .85rem;
  padding: .25rem .6rem;
  border: 1px solid var(--brand-link);
  background: transparent;
  color: var(--link);
  border-radius: .3rem;
  cursor: pointer;
}

/* Tables */
.table { width: 100%; border-collapse: collapse; margin: .5rem 0; }
.table th, .table td {
  text-align: left;
  padding: .5rem .6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table th { color: var(--heading); }
.table-scroll { overflow-x: auto; }
.row-actions { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.inline { display: inline; margin: 0; }
.inline-form { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; margin: 0; }
.inline-form select { width: auto; }
.filterbar { margin-bottom: 1rem; }
.btn--sm { padding: .3rem .7rem; font-size: .85rem; }
.test-signin { margin-top: 1rem; }

/* A role tag that is also a remove button (click to revoke). */
.tagbtn {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .1rem .5rem;
  border-radius: .35rem;
  border: 1px solid var(--brand-link);
  background: var(--brand-tint);
  color: var(--brand-primary);
  font: inherit;
  font-size: .85rem;
  font-weight: 700;
  cursor: pointer;
}
.tagbtn:hover { background: #fbe7e7; border-color: #8a1c1c; color: #6a1010; }
.tagbtn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
