/*
 * The Digital Haven's shell: the side menu, the top bar, the phone's bottom
 * tab bar, the hero and the stat cards.
 *
 * This is the Haven's own stylesheet. It shares nothing with the public
 * website's CSS, on purpose: the two may be separated one day, and the Haven
 * is meant to become an app. It is written phone-first, so everything below
 * the `min-width` breakpoints is what a phone gets and larger screens add to
 * it. Loaded after haven.css, whose components (cards, buttons, workbook
 * pages) it refines rather than replaces.
 */

:root {
  --shell-bg: #F6F5FB;             /* a cool, soft lavender-white behind the cards */
  --shell-line: rgba(53, 28, 66, 0.10);
  --shell-soft: #FFF0F7;          /* the active menu pill */
  --side-width: 250px;
  --top-height: 60px;
  --tabs-height: 64px;
  --tap: 44px;                    /* the smallest comfortable thumb target */

  --tile-pink: #FFE4F2;
  --tile-blue: #E3EEFB;
  --tile-yellow: #FFF1CF;
  --tile-mint: #DDF4EC;

  --radius: 18px;
  --shadow: 0 8px 28px rgba(53, 28, 66, 0.08);
}

body.haven {
  font-size: 16px;                 /* phone-first: no shrinking the text on small screens */
  background: var(--shell-bg);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

.skip-link {
  position: absolute; left: -999px; top: 8px; z-index: 100;
  background: #fff; color: var(--blue); padding: 10px 16px; border-radius: 10px;
}
.skip-link:focus { left: 12px; }

.haven a:focus-visible, .haven button:focus-visible, .haven summary:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 2px;
}

/* ---------- Layout: a phone is one column; a wide screen gains the side menu ---------- */

.haven-app { min-height: 100vh; }
.haven-body { min-width: 0; display: flex; flex-direction: column; min-height: calc(100vh - var(--top-height)); }

.haven-page {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 16px 14px calc(var(--tabs-height) + 32px + env(safe-area-inset-bottom));
  flex: 1;
}
.haven--bare .haven-page { padding-bottom: 48px; max-width: 760px; }

/* ---------- The top bar ---------- */

.haven-top {
  position: sticky; top: 0; z-index: 30;
  height: var(--top-height);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 0 12px;
  background: var(--blue);          /* the same blue as the public site's top bar */
  color: #fff;
  box-shadow: 0 2px 10px rgba(26, 31, 113, 0.25);
}
.haven-top__logo { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; }
.haven-top__logo img { height: 36px; width: auto; display: block; }
.haven-top__logo span {
  font-family: 'Poppins', sans-serif; font-weight: 600; font-size: 11px;
  letter-spacing: 0.16em; text-transform: uppercase; color: #FFB3D6;
  white-space: nowrap;
}
.haven-top__right { display: flex; align-items: center; gap: 4px; }

.haven-icon, .haven-top__menu {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  min-width: var(--tap); height: var(--tap);
  border-radius: 999px;
  border: 0; background: transparent;
  color: #fff; font-size: 19px; text-decoration: none; cursor: pointer;
}
.haven-icon:hover, .haven-top__menu:hover { background: rgba(255, 255, 255, 0.14); }
.haven-bar__bell-label { display: none; }
/* A small count tucked into the icon's top-right corner, so it never hides the icon itself.
   (haven.css still positions this class from the left; `left: auto` is what stops that
   from stretching the badge across the icon.) */
.haven-bar__badge {
  position: absolute; top: 2px; right: 0; left: auto;
  display: block; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 999px; background: var(--pink); color: #fff; box-shadow: 0 0 0 2px var(--blue);
  font: 700 10px/16px 'Poppins', sans-serif; text-align: center;
}

/* Who is signed in: an avatar on a phone, avatar and name on a wide screen. */
.haven-user { position: relative; }
.haven-user summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: 8px;
  min-height: var(--tap); padding: 0 4px; border-radius: 999px;
  color: #fff;
}
.haven-user summary::-webkit-details-marker { display: none; }
.haven-user__name, .haven-user__caret { display: none; }
.haven-user__name { font-weight: 600; font-size: 15px; color: #fff; }
.haven-user__caret { font-size: 11px; color: rgba(255, 255, 255, 0.75); }
.haven-user__panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 40;
  min-width: 230px; padding: 8px;
  background: #fff; border-radius: 16px; box-shadow: 0 16px 48px rgba(53, 28, 66, 0.18);
  border: 1px solid var(--shell-line);
}
.haven-user__panel a {
  display: flex; align-items: center; gap: 10px;
  min-height: var(--tap); padding: 0 12px; border-radius: 10px;
  color: var(--blue); text-decoration: none; font-weight: 600; font-size: 15px;
}
.haven-user__panel a i { width: 18px; color: var(--teal); text-align: center; }
.haven-user__panel a:hover { background: var(--shell-soft); }
.haven-user__who { padding: 8px 12px 10px; font-weight: 700; color: var(--blue); border-bottom: 1px solid var(--shell-line); margin-bottom: 6px; }
.haven-user__who small { display: block; font-weight: 500; color: var(--muted); }


/* ---------- Avatars ---------- */

.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 44px; height: 44px; border-radius: 50%; overflow: hidden;
  background: linear-gradient(135deg, var(--tile-pink), var(--tile-blue));
  color: var(--blue); font: 700 15px 'Poppins', sans-serif; letter-spacing: 0.02em;
  border: 2px solid #fff; box-shadow: 0 0 0 2px var(--pink);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar--sm { width: 36px; height: 36px; font-size: 13px; box-shadow: 0 0 0 2px var(--pink); }
.avatar--lg { width: 64px; height: 64px; font-size: 20px; }

/* ---------- The side menu: off-canvas on a phone ---------- */

.haven-side {
  position: fixed; inset: 0 auto 0 0; z-index: 60;
  width: min(84vw, 320px);
  display: flex; flex-direction: column;
  background: #fff;
  box-shadow: 0 0 48px rgba(53, 28, 66, 0.22);
  transform: translateX(-105%);
  transition: transform 0.22s ease;
  overflow-y: auto;
  padding-bottom: env(safe-area-inset-bottom);
}
.haven-menu-open .haven-side { transform: none; }
.haven-scrim {
  position: fixed; inset: 0; z-index: 55;
  background: rgba(26, 31, 113, 0.38);
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
}
.haven-menu-open .haven-scrim { opacity: 1; pointer-events: auto; }
.haven-menu-open { overflow: hidden; }

.haven-side__head { display: flex; align-items: center; justify-content: space-between; padding: 18px 18px 8px; }
.haven-side__logo { display: block; text-decoration: none; }
.haven-side__logo img { height: 54px; width: auto; display: block; }
.haven-side__logo span {
  display: block; margin: 4px 0 0 2px;
  font: 600 11px 'Poppins', sans-serif; letter-spacing: 0.22em; text-transform: uppercase; color: var(--muted);
}
.haven-side__close {
  width: var(--tap); height: var(--tap); border: 0; border-radius: 999px;
  background: var(--shell-soft); color: var(--blue); font-size: 18px; cursor: pointer;
}

.haven-nav { padding: 8px 12px 16px; flex: 1; }
.haven-nav__section { padding: 6px 0; }
.haven-nav__section + .haven-nav__section { border-top: 1px solid var(--shell-line); margin-top: 6px; padding-top: 12px; }
.haven-nav__title {
  padding: 0 14px 6px;
  font: 700 11px 'Poppins', sans-serif; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted);
}
.haven-nav__link {
  display: flex; align-items: center; gap: 14px;
  min-height: 48px; padding: 0 14px; margin: 2px 0;
  border-radius: 14px;
  color: var(--blue); text-decoration: none; font-weight: 600; font-size: 16px;
}
.haven-nav__link i { width: 22px; text-align: center; font-size: 17px; color: var(--blue); }
.haven-nav__link:hover { background: var(--shell-soft); }
.haven-nav__link.is-active { background: var(--tile-pink); }
.haven-nav__link.is-active i { color: var(--pink); }

.haven-side__foot {
  display: flex; align-items: center; gap: 10px;
  margin: 8px 18px 20px; padding: 16px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--tile-pink), var(--tile-blue));
  color: var(--blue); font: italic 600 17px 'Quicksand', sans-serif;
}
.haven-side__foot i { font-size: 22px; color: var(--pink); }
.haven-side__foot { margin-top: 6px; }
.haven-side__site {
  display: flex; align-items: center; gap: 8px;
  margin: 8px 20px 0; min-height: var(--tap);
  color: var(--muted); text-decoration: none; font: 600 13px 'Quicksand', sans-serif;
}
.haven-side__site:hover { color: var(--pink); }
.haven-side__site i { font-size: 12px; }

/* On the sign-in pages, a small way back to the public website, in the blue bar */
.haven-top__site {
  display: inline-flex; align-items: center; gap: 8px; min-height: var(--tap); padding: 0 12px;
  border-radius: 999px; color: #fff; text-decoration: none; font: 600 13px 'Quicksand', sans-serif;
}
.haven-top__site:hover { background: rgba(255, 255, 255, 0.14); }
.haven-top__site i { font-size: 12px; }

/* ---------- The phone's bottom tab bar ---------- */

.haven-tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  height: calc(var(--tabs-height) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  background: rgba(255, 255, 255, 0.97);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--shell-line);
  box-shadow: 0 -6px 24px rgba(53, 28, 66, 0.06);
}
.haven-tabs__link {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); text-decoration: none;
  font: 600 11px 'Poppins', sans-serif;
}
.haven-tabs__link i { font-size: 20px; }
.haven-tabs__link span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }
.haven-tabs__link.is-active { color: var(--pink); }
.haven-tabs__link.is-active i { transform: translateY(-1px); }

/* ---------- Wide screens: the menu stays open at the left ---------- */

@media (min-width: 960px) {
  :root { --top-height: 68px; }

  /* The menu sits just under the blue bar, which runs the full width of the page. */
  .haven-top { z-index: 40; padding: 0 28px; }
  .haven-top__logo img { height: 40px; }
  .haven-top__right { gap: 8px; }
  .haven-user summary { padding: 0 12px 0 4px; border: 1px solid rgba(255, 255, 255, 0.35); background: rgba(255, 255, 255, 0.08); }
  .haven-user summary:hover { background: rgba(255, 255, 255, 0.16); }
  .haven-user__name, .haven-user__caret { display: inline; }

  .haven-side {
    inset: var(--top-height) auto 0 0;
    transform: none; width: var(--side-width);
    box-shadow: none; border-right: 1px solid var(--shell-line);
    z-index: 20;
  }
  .haven-side__close, .haven-scrim, .haven-top__menu, .haven-nav__section--phone { display: none !important; }
  .haven-side__head { padding: 22px 22px 10px; }
  .haven-side__logo img { height: 64px; }
  .haven-side__logo span { margin-top: 6px; font-size: 12px; }

  /* With the menu showing, the logo lives at the top of it (with "The Haven" beneath),
     and the blue bar is left for messages, notifications and who is signed in. A page
     with no menu (the welcome flow) keeps the logo in the bar. */
  .haven-app:has(.haven-side) .haven-top { justify-content: flex-end; }
  .haven-app:has(.haven-side) .haven-top__logo { display: none; }
  .haven-app:has(.haven-side) .haven-body { margin-left: var(--side-width); }
  .haven--bare .haven-body { margin-left: 0 !important; }

  .haven-tabs { display: none; }
  .haven-page { padding: 28px 32px 64px; }
}

/* ---------- The hero: the photograph from the public home page ---------- */

.hero {
  position: relative; overflow: hidden; isolation: isolate;
  min-height: 210px;
  margin: 0 0 16px;
  border-radius: 22px;
  color: #fff;
  background: #2b2a5a url("../images/haven/hero.d7f8f582cb17.png") 38% center / cover no-repeat;
  display: flex; align-items: flex-end;
}
.hero::before {
  content: ''; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(180deg, rgba(26, 31, 113, 0.10) 0%, rgba(26, 31, 113, 0.62) 100%);
}
.hero__inner { padding: 20px 18px 18px; width: 100%; }
.hero__kicker { font: 700 11px 'Poppins', sans-serif; letter-spacing: 0.16em; text-transform: uppercase; color: #FFD3E8; }
.hero__title { margin: 4px 0 6px; font-size: 30px; line-height: 1.1; color: #fff; }
.hero__title i { color: #FF8EC0; font-size: 0.72em; margin-left: 4px; vertical-align: 2px; }
.hero__quote { margin: 0; max-width: 30ch; font: italic 600 15px/1.45 'Quicksand', sans-serif; color: rgba(255, 255, 255, 0.95); }

@media (min-width: 640px) {
  .hero { min-height: 250px; }
  .hero__inner { padding: 28px 32px; }
  .hero__title { font-size: 40px; }
  .hero__quote { font-size: 18px; max-width: 34ch; }
}
@media (min-width: 960px) {
  .hero { min-height: 280px; border-radius: 26px; background-position: center 40%; }
  .hero__title { font-size: 46px; }
}

/* ---------- Stat cards: a two-by-two grid on a phone, a row on a wide screen ---------- */

.stats {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
  margin: 0 0 20px; padding: 0; list-style: none;
}
.stats > li { display: flex; }          /* so every tile stretches to the tallest one in its row */
.stat {
  display: flex; align-items: center; gap: 10px;
  flex: 1; min-width: 0;
  min-height: 88px; padding: 12px;       /* room for a two-line label, so a long one never makes its tile taller */
  border-radius: 18px; text-decoration: none; color: var(--blue);
}
.stat--pink { background: var(--tile-pink); }
.stat--blue { background: var(--tile-blue); }
.stat--yellow { background: var(--tile-yellow); }
.stat--mint { background: var(--tile-mint); }
.stat__icon {
  flex: none; width: 42px; height: 42px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.75); font-size: 19px;
}
.stat--pink .stat__icon { color: #E24A92; }
.stat--blue .stat__icon { color: #2F6CC4; }
.stat--yellow .stat__icon { color: #C99A12; }
.stat--mint .stat__icon { color: #1E9E7A; }
.stat__number { font: 700 26px/1 'Raleway', sans-serif; display: block; }
.stat__label { display: block; font: 600 12px/1.25 'Poppins', sans-serif; color: var(--purple); margin-top: 3px; }
a.stat:hover { filter: brightness(0.98); box-shadow: var(--shadow); }

@media (min-width: 720px) {
  .stats { grid-template-columns: repeat(4, 1fr); gap: 14px; }
  .stat { padding: 16px; min-height: 96px; }
  .stat__number { font-size: 30px; }
}

/* ---------- Section headings that sit above a list ---------- */

.section-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin: 8px 0 14px;
}
.section-head h2 { margin: 0; font-size: 24px; }
.section-head p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }

/* ---------- Phone-first refinements to the existing components ---------- */

.card { border-radius: var(--radius); padding: 18px; }
.page-head { border-radius: 20px; padding: 18px 18px; margin-bottom: 18px; }
.page-head h1 { font-size: 26px; }
.flash { border-radius: 14px; }

.btn { min-height: var(--tap); display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-align: center; padding: 10px 24px; }
.btn--small { min-height: 40px; padding: 8px 18px; }
.btn--ghost { border-width: 1.5px; }
.btn--primary { background: linear-gradient(135deg, var(--teal), #0BB1C9); }
.btn--primary:hover { background: #037e96; }

input[type=text], input[type=email], input[type=password], input[type=date], input[type=time],
input[type=url], input[type=number], select, textarea { font-size: 16px; }   /* stops iOS zooming into a field */

@media (min-width: 720px) {
  .card { padding: 24px; }
  .page-head { padding: 22px 26px; }
  .page-head h1 { font-size: 30px; }
}

/* ---------- My Angels: a person, at a glance ---------- */

.angel-card {
  background: #fff; border-radius: 20px; box-shadow: var(--shadow);
  padding: 14px; margin-bottom: 12px;
  border-left-width: 5px;
}
.angel-card__row { display: flex; gap: 12px; align-items: flex-start; }
.angel-card__main { min-width: 0; flex: 1; }
.angel-card__head { align-items: flex-start; }
.angel-card__name { font-size: 18px; }
.angel-card__where { font-size: 13px; }
.angel-card__progress { display: flex; align-items: center; gap: 10px; margin: 8px 0 4px; }
.angel-card__bar { flex: 1; height: 8px; border-radius: 999px; background: #EDE8F1; overflow: hidden; }
.angel-card__bar > span { display: block; height: 100%; border-radius: inherit; background: var(--pink); }
.angel-card--on_track .angel-card__bar > span { background: #2fa36b; }
.angel-card--quiet .angel-card__bar > span { background: var(--yellow); }
.angel-card__count { font-size: 12px; color: var(--muted); white-space: nowrap; }
.angel-card__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
.angel-card__actions .btn { flex: 1 1 auto; }
.assign-form { display: flex; gap: 8px; flex: 1 1 100%; }
.assign-form select { flex: 1 1 0; min-width: 0; max-width: 100%; min-height: 40px; }
.assign-form .btn { flex: none; }

@media (min-width: 720px) {
  .angel-card { padding: 18px 20px; }
  .angel-card__name { font-size: 20px; }
  .angel-card__actions .btn { flex: 0 0 auto; }
  .assign-form { flex: 0 1 auto; }
}

/* A search box and a status filter, like the mockups */
.list-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.list-tools input[type=search] {
  flex: 1 1 200px; min-height: var(--tap); padding: 0 16px;
  border: 1.5px solid var(--shell-line); border-radius: 999px; background: #fff; font-size: 16px; color: var(--blue);
}

@media print { .haven-side, .haven-top, .haven-tabs, .haven-scrim, .hero, .stats { display: none !important; } .haven-body { margin: 0 !important; } }

/* ---------- My profile ---------- */

.avatar--xl { width: 96px; height: 96px; font-size: 30px; box-shadow: 0 0 0 3px var(--pink); }
.profile-photo__row { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.profile-photo__side { flex: 1 1 240px; min-width: 0; }
.profile-photo__form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.profile-photo__choose { position: relative; overflow: hidden; cursor: pointer; }
.profile-photo__choose input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }
.profile-facts { margin: 8px 0 12px; display: grid; gap: 8px; }
.profile-facts > div { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.profile-facts dt { flex: 0 0 170px; font: 600 13px 'Poppins', sans-serif; color: var(--muted); }
.profile-facts dd { margin: 0; color: var(--blue); font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 519px) {
  .profile-facts dt { flex: 0 0 100%; }
  .profile-photo__row { justify-content: center; text-align: center; }
  .profile-photo__side .card__hint { text-align: center !important; }
  .profile-photo__form { justify-content: center; }
}

/* My ALLy, in the menu under the name */
.haven-user__ally { margin: 4px 0; padding: 10px 12px; border-radius: 12px; background: var(--tile-pink); }
.haven-user__ally-title { font: 700 11px 'Poppins', sans-serif; letter-spacing: 0.14em; text-transform: uppercase; color: var(--purple); margin-bottom: 8px; }
.haven-user__ally-who { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--blue); }
.haven-user__panel .haven-user__ally-link { min-height: 36px; padding: 0 2px; margin-top: 4px; font-size: 14px; }
.haven-user__panel .haven-user__ally-link:hover { background: rgba(255, 255, 255, 0.6); }
.haven-user__ally-none { margin: 0; font-size: 13px; color: var(--purple); }

/* Stepping away: a required reason, one tap each */
.reason-list { border: 0; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.reason-option {
  display: flex; align-items: center; gap: 12px;
  min-height: 52px; padding: 0 16px;
  border: 1.5px solid rgba(53, 28, 66, 0.16); border-radius: 14px; background: #fff;
  cursor: pointer; font-weight: 600; color: var(--blue);
}
.reason-option input { width: 20px; height: 20px; accent-color: var(--teal); flex: none; }
.reason-option:has(input:checked) { border-color: var(--teal); background: #E9F8FB; }

/* ---------- Signing in, and Quick Exit ---------- */

.auth-card { max-width: 520px; margin-left: auto; margin-right: auto; }
.auth-card .page-actions { align-items: center; }
.auth-link { font-weight: 600; }
.auth-note { max-width: 520px; margin: 0 auto; }
.field__error { color: #b3374f; font-size: 14px; margin-top: 4px; }

/* Bottom right, on every page: above the phone's tab bar, clear of the content. */
.haven-exit {
  position: fixed; z-index: 45;
  right: 12px; bottom: calc(var(--tabs-height) + 12px + env(safe-area-inset-bottom));
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 42px; padding: 0 16px;
  border-radius: 999px; background: #E5484D; color: #fff;
  font: 700 13px 'Poppins', sans-serif; letter-spacing: 0.03em; text-decoration: none; white-space: nowrap;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}
.haven-exit:hover { background: #C93A3F; color: #fff; }
.haven-exit:focus-visible { outline: 3px solid #fff; outline-offset: 2px; box-shadow: 0 0 0 5px #C93A3F; }
.haven-exit i { font-size: 16px; }
.haven--bare .haven-exit { bottom: calc(16px + env(safe-area-inset-bottom)); }
@media (min-width: 960px) { .haven-exit { right: 24px; bottom: 24px; } }
@media print { .haven-exit { display: none !important; } }
