/* ============================================================================
   AMANAH — Responsive
   ============================================================================ */

/* ---- Nav: hamburger below 760px --------------------------------------------- */
@media (max-width: 760px) {
  .nav-inner {
    /* Adding the theme toggle as a 4th icon alongside the hamburger,
       "Record an amanah", and "Sign out" on dashboard/amanahs/amanah.html
       brought this row close enough to real 375px-width phones that it's
       worth trimming the outer gap/padding a little as a safety margin,
       rather than assuming the icon-collapsing below is exactly enough
       on its own. */
    gap: var(--space-3);
    padding-left: var(--space-4);
    padding-right: var(--space-4);
    overflow: hidden;
  }
  .nav-links {
    position: fixed;
    top: var(--nav-height);
    left: 0;
    right: 0;
    background: var(--charcoal-deep);
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    padding: var(--space-2) var(--space-5) var(--space-4);
    transform: translateY(-8px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--duration-base) var(--ease-out), transform var(--duration-base) var(--ease-out);
  }
  .nav-links.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
  }
  .nav-link {
    width: 100%;
    padding: var(--space-3) 0;
    border-bottom: 1px solid rgba(243, 240, 230, 0.08);
  }
  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    background: none;
    border: none;
    color: var(--ink-on-dark);
    cursor: pointer;
  }

  /* dashboard/amanahs/amanah.html pack brand + hamburger + "Record an
     amanah" + "Sign out" into one nav-inner row, with no wrap. That's
     ~380px+ of content in a viewport that can be as narrow as ~320px.
     Collapse the primary CTA to an icon-only button here; font-size: 0
     visually hides the label without removing it from the accessible
     name, so screen readers still announce "Record an amanah". */
  .nav-actions {
    gap: var(--space-2);
  }
  /* This selector must ONLY match the "Record an amanah" shortcut
     (dashboard/amanahs/amanah.html) — NOT the "Sign up" primary button
     that sits in the same .nav-actions slot on index.html/privacy.html.
     .btn-primary alone isn't specific enough (both are that class); the
     href to amanah-new.html is the one thing that reliably distinguishes
     them, since "Sign up" and "Record an amanah" never share a target. */
  .nav-actions .btn-primary[href="/amanah-new.html"] {
    position: relative;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    font-size: 0;
    flex-shrink: 0;
    overflow: hidden;
  }
  .nav-actions .btn-primary[href="/amanah-new.html"]::before {
    /* Absolutely positioned against the button's own box, not laid out
       as a flex child next to the (still-present-for-a11y, just
       zero-font-size) text node — that flex sibling plus the gap
       .btn inherits was what pushed the '+' off-center before. */
    content: '+';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: var(--text-lg);
    line-height: 1;
    font-weight: 600;
  }
}

@media (min-width: 761px) {
  .nav-toggle { display: none; }
}

/* ---- Stat grid --------------------------------------------------------------- */
@media (max-width: 640px) {
  .stat-grid {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }
  .money-summary {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }
}

/* ---- Detail layout ------------------------------------------------------------ */
@media (max-width: 860px) {
  .detail-layout {
    grid-template-columns: 1fr;
  }
}

/* ---- Field row ------------------------------------------------------------------ */
@media (max-width: 560px) {
  .field-row {
    grid-template-columns: 1fr;
  }
  .radio-group {
    flex-direction: column;
  }
}

/* ---- Record card on small screens ------------------------------------------------- */
@media (max-width: 560px) {
  .record-card {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }
  .record-card > div:last-child {
    grid-column: 1;
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-end;
    width: 100%;
  }
  .record-card-amount {
    order: 2;
  }
  .record-card-direction {
    order: 1;
  }
}

/* ---- Page header stacking -------------------------------------------------------- */
@media (max-width: 560px) {
  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .page-header .btn { width: 100%; }
}

/* ---- Auth card padding on very small screens --------------------------------------- */
@media (max-width: 400px) {
  .auth-card {
    padding: var(--space-6) var(--space-4);
  }
}
