/* =============================================================
   POSM Member Vault — additional styles for the secure area
   Loaded alongside the main public stylesheet (Fraunces / Source
   Serif 4 / Inter, rainforest / ochre / cream palette).
   ============================================================= */

/* Body chrome for the portal */
body.vault {
  background: var(--bg-alt);
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

/* Top utility bar — replaces the marketing nav inside the Vault */
.vault-bar {
  background: var(--rainforest-deep);
  color: var(--cream);
  border-bottom: 3px solid var(--ochre);
}
.vault-bar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.6rem;   /* horizontal margin so the logo/menu aren't jammed to the edges, aligned with the sidebar */
  gap: var(--space-md);
  flex-wrap: wrap;
}
.vault-brand {
  font-family: var(--font-display);
  color: var(--cream);
  text-decoration: none;
  font-size: 1rem;
  line-height: 1.2;
}
.vault-brand small {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
  margin-top: 3px;
}
.vault-user {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-family: var(--font-sans);
  font-size: 0.86rem;
  color: rgba(245,239,225,0.9);
}
.vault-user .role {
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
  padding: 2px 8px;
  background: rgba(201,162,77,0.12);
  border-radius: 3px;
}
.vault-user a {
  color: var(--cream);
  text-decoration: none;
  border-bottom: 1px solid rgba(245,239,225,0.3);
}
.vault-user a:hover { color: var(--gold); }

/* Layout: sidebar + main */
.vault-layout {
  display: grid;
  grid-template-columns: 1fr;
  flex: 1;
  width: 100%;
  /* Full-width app: the sidebar sits flush at the left edge (no centred
     container leaving a cream margin beside the brown sidebar). */
}
@media (min-width: 880px) {
  .vault-layout { grid-template-columns: 240px 1fr; }
}

.vault-sidebar {
  background: var(--surface);
  color: var(--text);
  padding: 1.5rem 0;
  border-right: 1px solid var(--border);
}
.vault-sidebar h4 {
  font-family: var(--font-sans);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
  margin: 1.4rem 1.6rem 0.6rem;
}
.vault-sidebar ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.vault-sidebar a {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem 1.6rem;
  color: rgba(26,20,17,0.74);
  text-decoration: none;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  border-left: 3px solid transparent;
  transition: all 180ms var(--ease);
}
.vault-sidebar a:hover {
  color: var(--text);
  background: rgba(26,20,17,0.045);
}
.vault-sidebar a[aria-current="page"] {
  color: var(--text);
  background: rgba(183,110,44,0.12);
  border-left-color: var(--ochre);
  font-weight: 600;
}
.vault-sidebar a svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 1.6;
  flex-shrink: 0;
}

.vault-main {
  padding: clamp(1.5rem, 4vw, 3rem) clamp(1.25rem, 3vw, 2.5rem);
  background: var(--bg-alt);
}

/* Page heading bar */
.vault-page-head {
  margin-bottom: var(--space-md);
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
}
.vault-page-head h1 {
  font-size: var(--step-3);
  margin: 0;
  letter-spacing: -0.015em;
}
.vault-page-head p {
  margin: 0.5em 0 0;
  color: var(--text-muted);
  max-width: 60ch;
}
.vault-page-head .actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

/* Cards & tables */
.vault-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: clamp(1.2rem, 2.5vw, 1.8rem);
  margin-bottom: 1.4rem;
}
.vault-card h2 { font-size: var(--step-2); margin-top: 0; }
.vault-card h3 { font-size: var(--step-1); margin-top: 0; }

.vault-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-body);
  font-size: 0.95rem;
}
.vault-table th,
.vault-table td {
  text-align: left;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.vault-table th {
  font-family: var(--font-sans);
  font-size: 0.74rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  background: var(--bg-alt);
  border-bottom: 2px solid var(--border);
}
.vault-table tr:hover td { background: var(--bg-alt); }
.vault-table .meta {
  font-size: 0.82rem;
  color: var(--text-muted);
}
.vault-table .actions { white-space: nowrap; }
.vault-table .actions a {
  margin-right: 0.6rem;
  font-family: var(--font-sans);
  font-size: 0.85rem;
}

/* Login screen */
.vault-login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
  background: var(--bg);
}
@media (min-width: 920px) {
  .vault-login-shell { grid-template-columns: 1fr 1fr; }
}
.vault-login-aside {
  background: var(--rainforest);
  color: var(--cream);
  padding: clamp(2rem, 5vw, 4rem);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.vault-login-aside::after {
  content: "";
  position: absolute;
  right: -120px; top: 30%;
  width: 280px; height: 280px;
  border: 1px solid var(--ochre);
  opacity: 0.18;
  border-radius: 50%;
  pointer-events: none;
}
.vault-login-aside h1 {
  color: var(--cream);
  font-size: var(--step-4);
  line-height: 1.15;
  margin: 0 0 1rem;
}
.vault-login-aside .eyebrow { color: var(--gold); }
.vault-login-aside .eyebrow::before { background: var(--gold); }
.vault-login-aside p { color: rgba(245,239,225,0.85); max-width: 38ch; }
.vault-login-aside small {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  color: rgba(245,239,225,0.55);
  margin-top: 2rem;
}

.vault-login-form {
  padding: clamp(2rem, 5vw, 4rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.vault-login-form .inner {
  max-width: 380px;
  width: 100%;
  margin: 0 auto;
}
.vault-login-form h2 {
  font-size: var(--step-3);
  margin-top: 0;
}

/* Flash messages */
.flash {
  padding: 1rem 1.2rem;
  border-radius: var(--radius);
  margin-bottom: 1.4rem;
  font-size: 0.94rem;
  border-left: 3px solid var(--ochre);
}
.flash-success { background: rgba(31,51,41,0.06);  border-left-color: var(--rainforest); color: var(--rainforest-deep); }
.flash-error   { background: rgba(178,34,34,0.06); border-left-color: #b22222;            color: #6b1010; }
.flash-info    { background: rgba(183,110,44,0.06);border-left-color: var(--ochre);       color: var(--rainforest-deep); }

/* Stat tiles for dashboard */
.vault-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.6rem;
}
.vault-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.2rem 1.4rem;
  position: relative;
}
.vault-stat::before {
  content: "";
  position: absolute; top: 0; left: 0;
  width: 3px; height: 100%;
  background: var(--ochre);
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}
.vault-stat .num {
  font-family: var(--font-display);
  font-size: var(--step-4);
  color: var(--rainforest);
  line-height: 1;
  font-weight: 400;
  margin: 0.2em 0;
}
.vault-stat .label {
  font-family: var(--font-sans);
  font-size: 0.74rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}

/* Document category badges */
.vault-cat {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 20px;
  font-weight: 600;
}
.vault-cat-governance { background:#dbe8df; color:#1F3329; }
.vault-cat-meetings   { background:#e9dccc; color:#6b5a44; }
.vault-cat-cultural   { background:#B76E2C; color:#fff; }
.vault-cat-finance    { background:#d8d4c2; color:#3a3527; }
.vault-cat-calendar   { background:#cde0d4; color:#1F3329; }
.vault-cat-other      { background:#e6e2d6; color:#5a5040; }

/* Restricted indicator */
.vault-restricted {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  color: var(--ochre);
  font-family: var(--font-sans);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* Footer for vault */
.vault-footer {
  background: var(--rainforest-deep);
  color: rgba(245,239,225,0.55);
  padding: 1.5rem 0;
  font-size: 0.82rem;
  font-family: var(--font-sans);
  text-align: center;
  margin-top: auto;
}

/* Detail boxes */
.detail-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 1.5rem;
  font-size: 0.94rem;
}
.detail-grid dt {
  font-family: var(--font-sans);
  font-size: 0.74rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  align-self: center;
}
.detail-grid dd { margin: 0; }

/* Inline button-link */
.btn-sm {
  padding: 0.45rem 0.9rem;
  font-size: 0.84rem;
}

.role-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-family: var(--font-sans);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
  background: var(--sandstone);
  color: var(--rainforest-deep);
}
.role-pill-admin        { background: var(--rainforest-deep); color: var(--gold); }
.role-pill-director     { background: var(--ochre);            color: var(--cream); }
.role-pill-elder_member { background: var(--rainforest);       color: var(--cream); }
.role-pill-staff        { background: var(--bark-muted);       color: var(--cream); }

/* ---- Accessibility ---- */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: #ffd400;
    color: #1c1814;
    padding: 12px 20px;
    font-family: var(--font-sans, sans-serif);
    font-weight: 600;
    font-size: 15px;
    text-decoration: none;
    z-index: 10000;
    border: 2px solid #1c1814;
}
.skip-link:focus {
    left: 12px;
    top: 12px;
    outline: 3px solid #1c1814;
    outline-offset: 2px;
}
:focus-visible {
    outline: 3px solid #ffd400;
    outline-offset: 2px;
    border-radius: 2px;
}

/* Visually hidden — announced by screen readers, invisible to sight */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* =============================================================
   MOBILE RESPONSIVE LAYER (added 22 Sep 2026 for POSM demo)
   Everything above this line is the original desktop styling.
   Below is additive: it only kicks in below 880px and does not
   change desktop behaviour. Pure CSS, no JS or HTML changes.
   ============================================================= */

/* ---------- Vault bar (top black strip) ---------- */
@media (max-width: 880px) {
  .vault-bar-inner {
    padding: 0.6rem 0;
    gap: 0.5rem;
  }
  .vault-brand {
    font-size: 0.9rem;
    line-height: 1.1;
  }
  .vault-brand small {
    font-size: 0.58rem;
    letter-spacing: 0.12em;
    margin-top: 2px;
  }
  .vault-user {
    font-size: 0.78rem;
    gap: 0.6rem;
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  .vault-user .role {
    font-size: 0.62rem;
    padding: 1px 6px;
  }
}
@media (max-width: 480px) {
  /* On tiny screens hide the brand tagline entirely to save space */
  .vault-brand small { display: none; }
  .vault-user > *:not(.role):not(a) { display: none; }
}

/* ---------- Sidebar becomes horizontal scrollable tab strip ---------- */
@media (max-width: 880px) {
  .vault-layout {
    /* Undo the sidebar column, stack cleanly */
    grid-template-columns: 1fr;
  }
  .vault-sidebar {
    padding: 0;
    background: var(--surface);
    border-right: none;
    border-bottom: 2px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 30;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;      /* Firefox — hide scrollbar */
  }
  .vault-sidebar::-webkit-scrollbar { display: none; }   /* Chrome/Safari */

  /* Section headers (Member area / Administration) hide on mobile —
     they cause the tab strip to break into rows and confuse the layout.
     The icons + labels are self-explanatory enough. */
  .vault-sidebar h4 { display: none; }

  .vault-sidebar ul {
    display: flex;
    flex-wrap: nowrap;
    padding: 0.4rem 0.6rem;
    gap: 0.15rem;
    min-width: max-content;   /* let content push wider than viewport */
  }
  .vault-sidebar li {
    flex: 0 0 auto;
  }
  .vault-sidebar a {
    /* Chip-style tab */
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 0.9rem;
    border-left: none;
    border-bottom: 2px solid transparent;
    border-radius: 6px 6px 0 0;
    font-size: 0.84rem;
    white-space: nowrap;
    min-height: 44px;         /* iOS touch target minimum */
  }
  .vault-sidebar a[aria-current="page"] {
    background: rgba(183,110,44,0.22);
    border-left-color: transparent;
    border-bottom-color: var(--ochre);
  }
  .vault-sidebar a svg {
    width: 14px;
    height: 14px;
  }
  /* Attention badges — shrink slightly for the compact strip */
  .vault-sidebar .module-badge {
    transform: scale(0.85);
    margin-left: 4px;
  }
}

/* ---------- Main content area ---------- */
@media (max-width: 880px) {
  .vault-main {
    padding: 1.1rem 0.9rem 2rem;
  }
}
@media (max-width: 480px) {
  .vault-main {
    padding: 0.9rem 0.7rem 1.5rem;
  }
}

/* ---------- Page head (H1 + action buttons) ---------- */
@media (max-width: 880px) {
  .vault-page-head {
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    gap: 0.6rem;
  }
  .vault-page-head h1 {
    font-size: clamp(1.4rem, 6vw, 1.9rem);
    line-height: 1.15;
  }
  .vault-page-head p {
    font-size: 0.9rem;
  }
  .vault-page-head .actions {
    width: 100%;
    justify-content: flex-start;
  }
  .vault-page-head .actions .btn,
  .vault-page-head .actions a {
    font-size: 0.85rem;
    padding: 0.5rem 0.85rem;
    min-height: 40px;
  }
}

/* ---------- Cards ---------- */
@media (max-width: 880px) {
  .vault-card {
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 8px;
  }
  .vault-card h2 { font-size: 1.15rem; }
  .vault-card h3 { font-size: 1rem; }
}

/* ---------- Tables (horizontal scroll) ---------- */
@media (max-width: 880px) {
  /* Wrap tables in a scrolling container. We add this to the table
     itself using display: block so it scrolls its own body. Not
     ideal semantically, but it's the only way without changing HTML. */
  .vault-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    font-size: 0.86rem;
    white-space: nowrap;
    max-width: 100%;
  }
  .vault-table thead,
  .vault-table tbody,
  .vault-table tr {
    display: table;
    width: 100%;
    table-layout: auto;
  }
  .vault-table th,
  .vault-table td {
    padding: 0.6rem 0.7rem;
  }
  .vault-table th {
    font-size: 0.66rem;
  }
  /* Meta / secondary text stays wrapped */
  .vault-table .meta {
    white-space: normal;
    font-size: 0.78rem;
  }
  /* Action links get more tap room */
  .vault-table .actions a {
    display: inline-block;
    padding: 6px 0;
    margin-right: 0.4rem;
    min-height: 32px;
  }
}

/* ---------- Stat tiles (dashboard) ---------- */
@media (max-width: 880px) {
  .vault-stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
    margin-bottom: 1rem;
  }
  .vault-stat {
    padding: 0.85rem 1rem;
  }
  .vault-stat .num {
    font-size: clamp(1.6rem, 8vw, 2.2rem);
  }
  .vault-stat .label {
    font-size: 0.66rem;
  }
}
@media (max-width: 380px) {
  .vault-stats {
    grid-template-columns: 1fr;
  }
}

/* ---------- Detail grid (definition list) ---------- */
@media (max-width: 640px) {
  .detail-grid {
    grid-template-columns: 1fr;
    gap: 0.2rem 0;
  }
  .detail-grid dt {
    margin-top: 0.7rem;
    color: var(--text-muted);
  }
  .detail-grid dt:first-child { margin-top: 0; }
  .detail-grid dd {
    font-size: 1rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--border);
  }
}

/* ---------- Login screen — single column stack ---------- */
@media (max-width: 920px) {
  .vault-login-shell {
    grid-template-columns: 1fr;
  }
  .vault-login-aside {
    padding: 1.5rem 1.2rem 2rem;
  }
  .vault-login-aside::after {
    display: none;   /* circle decoration hidden on mobile */
  }
  .vault-login-aside h1 {
    font-size: clamp(1.6rem, 7vw, 2.4rem);
  }
  .vault-login-aside small {
    margin-top: 1rem;
  }
  .vault-login-form {
    padding: 1.5rem 1.2rem 2.5rem;
  }
}

/* ---------- Form controls — one consistent styled look at ALL widths ---------- */
.vault-main input[type="text"],
.vault-main input[type="email"],
.vault-main input[type="password"],
.vault-main input[type="number"],
.vault-main input[type="date"],
.vault-main input[type="time"],
.vault-main input[type="tel"],
.vault-main input[type="search"],
.vault-main input[type="url"],
.vault-main select,
.vault-main textarea {
  font: inherit;
  color: var(--text, #2A2118);
  background-color: var(--surface, #FFFFFF);
  border: 1.5px solid rgba(42, 33, 24, 0.20);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  box-sizing: border-box;
  max-width: 100%;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.vault-main input[type="text"],
.vault-main input[type="email"],
.vault-main input[type="password"],
.vault-main input[type="number"],
.vault-main input[type="url"],
.vault-main input[type="search"],
.vault-main textarea { width: 100%; max-width: 480px; }
.vault-main textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.vault-main select { min-width: 200px; }
.vault-main input:focus,
.vault-main select:focus,
.vault-main textarea:focus {
  outline: none;
  border-color: var(--gold, #C09C48);
  box-shadow: 0 0 0 3px rgba(192, 156, 72, 0.22);
}
/* Styled dropdown with a custom chevron so selects match across browsers */
.vault-main select {
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238A7A62' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.3rem;
}
/* File picker button styled to match the suite */
.vault-main input[type="file"] { font: inherit; color: var(--text-muted, #6b5d47); max-width: 100%; }
.vault-main input[type="file"]::file-selector-button,
.vault-main input[type="file"]::-webkit-file-upload-button {
  font: inherit; cursor: pointer; margin-right: 0.8rem;
  background: var(--rainforest, #3D3227); color: var(--cream, #F5EFE1);
  border: 0; border-radius: 8px; padding: 0.55rem 1rem;
  transition: opacity .15s ease;
}
.vault-main input[type="file"]::file-selector-button:hover { opacity: .9; }

/* ---------- Forms & inputs — touch targets ---------- */
@media (max-width: 880px) {
  .vault-main input[type="text"],
  .vault-main input[type="email"],
  .vault-main input[type="password"],
  .vault-main input[type="number"],
  .vault-main input[type="date"],
  .vault-main input[type="time"],
  .vault-main input[type="tel"],
  .vault-main input[type="search"],
  .vault-main select,
  .vault-main textarea {
    font-size: 16px;      /* iOS won't zoom on focus if >=16px */
    padding: 0.7rem 0.75rem;
    min-height: 44px;
    max-width: 100%;
    box-sizing: border-box;
  }
  .vault-main select { padding-right: 2.3rem; }   /* keep the chevron clear on mobile */
  .vault-main textarea {
    min-height: 100px;
  }
  .vault-main .btn,
  .vault-main button {
    min-height: 44px;
    padding: 0.7rem 1.1rem;
    font-size: 0.95rem;
  }
}

/* ---------- Flash messages ---------- */
@media (max-width: 880px) {
  .flash {
    font-size: 0.88rem;
    padding: 0.8rem 0.9rem;
    margin-bottom: 1rem;
  }
}

/* ---------- Role pills & category badges ---------- */
@media (max-width: 480px) {
  .role-pill,
  .vault-cat {
    font-size: 0.62rem;
    padding: 2px 6px;
    letter-spacing: 0.08em;
  }
}

/* ---------- Footer ---------- */
@media (max-width: 880px) {
  .vault-footer {
    padding: 1rem 0.8rem;
    font-size: 0.74rem;
  }
}
