/* ============================================================
   Community Connect Housing — shared stylesheet
   Used by every page. Design tokens live in :root so a
   backend/theme layer can override them in one place later.
   ============================================================ */

:root {
  /* Community Connect Housing palette */
  --white:      #FFFFFF;
  --taupe:      #C6BBAD;
  --sage:       #6F7970;
  --navy:       #13283A;
  --deep-navy:  #151B23;

  /* Brand + surfaces */
  --ink:        var(--deep-navy); /* primary text */
  --pine:       var(--navy);      /* primary brand */
  --pine-deep:  var(--deep-navy); /* darker brand for hovers/footers */
  --pine-tint:  #E8ECEA;          /* washed sage fill */
  --bg:         #F5F5F3;          /* warm paper background */
  --surface:    var(--white);     /* cards, panels */
  --line:       #D8D6D1;          /* taupe-derived hairlines */
  --muted:      var(--sage);      /* secondary text */

  /* Availability signal system (used app-wide) */
  --open:       var(--sage);      /* beds available */
  --open-bg:    #EAEFEA;
  --limited:    #8A7562;          /* taupe-derived warning */
  --limited-bg: #F3EEE9;
  --full:       var(--deep-navy); /* no beds / alerts */
  --full-bg:    #E8EBEE;

  /* Type */
  --display: "Space Grotesk", "Segoe UI", system-ui, sans-serif;
  --body:    "Inter", system-ui, -apple-system, sans-serif;
  --mono:    "Space Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* Structure */
  --radius:   10px;
  --radius-sm: 7px;
  --shadow:   0 1px 2px rgba(21,27,35,.06), 0 6px 20px rgba(21,27,35,.05);
  --shadow-lg:0 8px 40px rgba(21,27,35,.12);
  --wrap:     1140px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--body);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--display); line-height: 1.12; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(2rem, 5vw, 3.3rem); font-weight: 600; }
h2 { font-size: clamp(1.5rem, 3.4vw, 2.1rem); font-weight: 600; }
h3 { font-size: 1.2rem; font-weight: 600; }
p  { margin: 0 0 1rem; }
a  { color: var(--pine); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 20px; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.eyebrow {
  font-family: var(--mono); font-size: .74rem; letter-spacing: .16em;
  text-transform: uppercase; color: var(--pine); margin: 0 0 .8rem;
}
.center { text-align: center; }
.hide { display: none !important; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  font-family: var(--body); font-weight: 600; font-size: .95rem;
  padding: .7em 1.25em; border-radius: var(--radius-sm);
  border: 1.5px solid transparent; cursor: pointer; text-decoration: none;
  transition: transform .06s ease, background .15s ease, border-color .15s ease;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--pine); color: var(--white); }
.btn-primary:hover { background: var(--pine-deep); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--pine); color: var(--pine); }
.btn-quiet { background: var(--pine-tint); color: var(--pine-deep); }
.btn-quiet:hover { background: #DDE5E2; }
.btn-danger { background: var(--full); color: var(--white); }
.btn-danger:hover { background: var(--navy); }
.btn-sm { padding: .45em .85em; font-size: .85rem; }
.btn-block { width: 100%; }
.btn:focus-visible { outline: 3px solid rgba(19,40,58,.4); outline-offset: 2px; }

/* ---------- Top navigation (shared) ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 40; }
.nav { display: flex; align-items: center; gap: 1.5rem; height: 66px; }
.brand { display: flex; align-items: center; gap: .65rem; font-family: var(--display); font-weight: 600; font-size: 1.12rem; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark-image { width: 36px; height: 36px; object-fit: contain; flex-shrink: 0; }
.brand-name { display: grid; gap: 2px; line-height: 1; }
.brand-name-main { color: inherit; }
.brand-name-sub { color: var(--sage); font-family: var(--mono); font-size: .58rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
.brand .mark {
  width: 30px; height: 30px; border-radius: 8px; background: var(--pine);
  flex-shrink: 0; display: grid; place-items: center; color: #fff; font-family: var(--mono); font-size: .8rem; font-weight: 700;
}
.nav-links { display: flex; gap: 1.35rem; margin-left: .5rem; }
.nav-links a { color: var(--ink); font-size: .93rem; font-weight: 500; }
.nav-links a:hover { color: var(--pine); text-decoration: none; }
.nav-links a.active { color: var(--pine); }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: .7rem; }
.nav-toggle { display: none; background: none; border: 1px solid var(--line); border-radius: 7px; padding: .4rem .55rem; cursor: pointer; font-size: 1.1rem; line-height: 1; }

/* ---------- Live indicator + status pills (the signature system) ---------- */
.live { display: inline-flex; align-items: center; gap: .45em; font-family: var(--mono); font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--open); font-weight: 700; }
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--open); box-shadow: 0 0 0 0 rgba(111,121,112,.6); animation: pulse 2s infinite; }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(111,121,112,.55); }
  70%  { box-shadow: 0 0 0 7px rgba(111,121,112,0); }
  100% { box-shadow: 0 0 0 0 rgba(111,121,112,0); }
}

.pill {
  display: inline-flex; align-items: center; gap: .4em;
  font-family: var(--mono); font-size: .72rem; font-weight: 700; letter-spacing: .04em;
  padding: .28em .7em; border-radius: 100px; text-transform: uppercase; white-space: nowrap;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill-open    { color: var(--open);    background: var(--open-bg); }
.pill-limited { color: var(--limited); background: var(--limited-bg); }
.pill-full    { color: var(--full);    background: var(--full-bg); }
.pill-plain::before { display: none; }
.pill-verified { color: var(--pine); background: var(--pine-tint); }

.ts { font-family: var(--mono); font-size: .76rem; color: var(--muted); }

/* ---------- Badges ----------
   Compact labels for counts, attributes and plan tiers.
   (Status *pills* above carry live availability; badges are neutral labels.)
*/
.badge {
  display: inline-flex; align-items: center; gap: .35em;
  font-family: var(--mono); font-size: .7rem; font-weight: 700; letter-spacing: .04em;
  padding: .24em .6em; border-radius: 6px; text-transform: uppercase; white-space: nowrap;
  background: var(--pine-tint); color: var(--pine-deep);
}
.badge-neutral { background: #ECEEEB; color: var(--muted); }
.badge-open    { background: var(--open-bg);    color: var(--open); }
.badge-limited { background: var(--limited-bg); color: var(--limited); }
.badge-full    { background: var(--full-bg);    color: var(--full); }
.badge-count   { background: var(--pine); color: #fff; border-radius: 100px; padding: .18em .55em; min-width: 1.5em; justify-content: center; }
.badge-outline { background: transparent; color: var(--muted); border: 1px solid var(--line); }

/* ---------- Cards / panels ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 22px; }
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; min-width: 640px; }
table.data th, table.data td { text-align: left; padding: 13px 16px; border-bottom: 1px solid var(--line); font-size: .92rem; }
table.data th { font-family: var(--mono); font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); background: #F7F7F5; font-weight: 700; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover, table.data tbody tr:hover { background: #F7F7F5; }
.num { font-family: var(--mono); font-weight: 700; }

/* ---------- Forms ---------- */
.field { margin-bottom: 1.1rem; }
.field label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .35rem; }
.field .hint { font-size: .8rem; color: var(--muted); margin-top: .3rem; }
.input, .select, .textarea {
  width: 100%; font-family: var(--body); font-size: .95rem; color: var(--ink);
  padding: .7em .8em; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  background: var(--white); transition: border-color .15s ease;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--pine); box-shadow: 0 0 0 3px rgba(19,40,58,.12); }
.textarea { min-height: 96px; resize: vertical; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ---------- Alerts / banners ---------- */
.alert { display: flex; gap: .75rem; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius); border: 1px solid; font-size: .92rem; }
.alert .a-icon { font-family: var(--mono); font-weight: 700; }
.alert-danger { background: var(--full-bg); border-color: #eec3bd; color: #7d2b21; }
.alert-warn   { background: var(--limited-bg); border-color: #efd8ac; color: #7a4f13; }
.alert-info   { background: var(--pine-tint); border-color: #CBD8D2; color: var(--pine-deep); }
.alert a:not(.btn) { color: inherit; text-decoration: underline; font-weight: 600; }

/* ---------- Sections / footer ---------- */
.section { padding: 72px 0; }
.section-tight { padding: 48px 0; }
footer.site { background: var(--deep-navy); color: #D3D8D5; padding: 48px 0 32px; margin-top: 40px; }
footer.site a { color: #dfe8e5; }
footer.site h4 { color: #fff; font-size: .95rem; }
footer.site .brand-name-sub { color: var(--taupe); }
.foot-grid { display: grid; grid-template-columns: 1.6fr 1fr 1fr 1fr; gap: 28px; }
.foot-links { display: flex; flex-direction: column; gap: .5rem; font-size: .9rem; }
.foot-bottom { border-top: 1px solid rgba(255,255,255,.12); margin-top: 32px; padding-top: 20px; font-size: .82rem; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; }

/* ---------- Misc helpers ---------- */
.stack > * + * { margin-top: 1rem; }
.tag { font-family: var(--mono); font-size: .72rem; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: .1em .5em; }
.divider { height: 1px; background: var(--line); border: 0; margin: 0; }

/* ============================================================
   App shell + sidebar (logged-in / member pages)
   Usage:
   <div class="app">
     <aside class="sidebar"> ... </aside>
     <div class="app-body">
       <header class="app-bar"> ... </header>
       <main class="main"> ... </main>
     </div>
   </div>
   ============================================================ */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 244px; flex-shrink: 0; background: var(--ink); color: #c7d3d0;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { color: #fff; padding: 20px 20px 16px; }
.sidebar .brand-mark-image { width: 40px; height: 40px; }
.sidebar .brand-mark-image, footer.site .brand-mark-image { background: var(--white); border-radius: 50%; padding: 3px; }
.sidebar .brand .mark { background: var(--pine); }
.sidebar .brand-name { min-width: 0; line-height: 1.2; }
.side-section { font-family: var(--mono); font-size: .66rem; letter-spacing: .14em; text-transform: uppercase; color: #7f918d; padding: 16px 20px 6px; }
.side-nav { display: flex; flex-direction: column; padding: 4px 12px; gap: 2px; }
.side-link {
  display: flex; align-items: center; gap: .7rem; padding: .62rem .75rem; border-radius: 8px;
  color: #cdd8d5; font-size: .93rem; font-weight: 500;
}
.side-link:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.side-link.active { background: var(--pine); color: #fff; }
.side-link .ico { width: 20px; text-align: center; font-family: var(--mono); }
.side-link .badge { margin-left: auto; font-family: var(--mono); font-size: .68rem; background: rgba(255,255,255,.15); padding: .1em .5em; border-radius: 100px; }
.side-foot { margin-top: auto; padding: 16px; border-top: 1px solid rgba(255,255,255,.1); }
.side-user { display: flex; align-items: center; gap: .6rem; font-size: .85rem; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--pine); color: #fff; display: grid; place-items: center; font-family: var(--mono); font-size: .78rem; font-weight: 700; flex-shrink: 0; }

.app-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-bar {
  height: 62px; background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 1rem; padding: 0 22px; position: sticky; top: 0; z-index: 30;
}
.app-bar .page-title { font-family: var(--display); font-weight: 600; font-size: 1.05rem; }
.app-bar .app-actions { margin-left: auto; display: flex; align-items: center; gap: .7rem; }
.side-open { display: none; background: none; border: 1px solid var(--line); border-radius: 7px; padding: .35rem .5rem; cursor: pointer; font-size: 1.1rem; line-height: 1; }
.main { padding: 26px 22px 60px; max-width: 1100px; width: 100%; }
.scrim { display: none; }

/* Stat tiles used on member pages */
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.stat .label { font-family: var(--mono); font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.stat .value { font-family: var(--display); font-size: 2rem; font-weight: 600; line-height: 1.1; margin-top: 4px; }

/* ============================================================
   Responsive — mobile-first friendly
   ============================================================ */
@media (max-width: 860px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .foot-grid { grid-template-columns: 1fr 1fr; }
  .nav-links { display: none; }
  .nav-links.open {
    display: flex; flex-direction: column; position: absolute; top: 66px; left: 0; right: 0;
    background: var(--surface); border-bottom: 1px solid var(--line); padding: 12px 20px; gap: .25rem; box-shadow: var(--shadow);
  }
  .nav-links.open a { padding: .6rem 0; border-bottom: 1px solid var(--line); }
  .nav-toggle { display: inline-flex; }
  .nav-right .btn-ghost { display: none; }
  .row-2 { grid-template-columns: 1fr; }

  /* Sidebar becomes an off-canvas drawer on phones */
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 60; height: 100vh;
    transform: translateX(-100%); transition: transform .22s ease;
  }
  .app.nav-open .sidebar { transform: translateX(0); }
  .app.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(21,27,35,.45); z-index: 55; }
  .side-open { display: inline-flex; }
  .main { padding: 18px 16px 56px; }
  .app-bar { padding: 0 16px; }
}

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

/* ============================================================
   Mobile usability (phones) — larger tap targets, no iOS zoom,
   overflow-safe headers. Applies on top of the layout rules above.
   ============================================================ */
@media (max-width: 640px) {
  .nav { gap: .6rem; }
  .nav .brand { min-width: 0; font-size: .9rem; line-height: 1.12; }
  .nav .brand-name { min-width: 0; }
  .nav-right { flex-shrink: 0; gap: .4rem; }
  /* Form fields: 16px prevents iOS Safari auto-zoom on focus, and
     the taller controls are easier to tap and fill. */
  .input, .select, .textarea, .prop-select {
    font-size: 16px;
    padding-top: .68em; padding-bottom: .68em;
  }

  /* Minimum comfortable tap targets (~44px) for all buttons/links styled as buttons */
  .btn { min-height: 44px; }
  .btn-sm { min-height: 40px; padding-top: .5em; padding-bottom: .5em; }

  /* Chips and toggles used as controls */
  .chip, .fchip, .cchip { min-height: 38px; display: inline-flex; align-items: center; }

  /* App bar: keep the primary action reachable, never let the header overflow.
     The page title truncates instead of pushing the action button off-screen,
     and the status pill is dropped on small screens. */
  .app-bar { gap: .6rem; }
  .app-bar .page-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .app-bar .pill { display: none; }
  .app-bar .app-actions { flex-shrink: 0; }

  /* Row action button groups (tables) get a touch more spacing */
  table.data td .row-actions { gap: 8px; }

  /* Public nav: surface Login inside the mobile menu so it's never lost */
  .nav-links.open .m-login { display: block; }
}

/* Login link that only appears inside the mobile nav drawer */
.nav-links .m-login { display: none; }
