/* ==========================================================================
   RoomCompare — Layout: navigation, content column, page structure
   Top navigation over a centred column. Dropping the prototype's 280px
   sidebar returns that width to the comparison table, which is the point.
   ========================================================================== */

/* --- Skip link ----------------------------------------------------------- */

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: calc(-1 * var(--space-7));
  z-index: 60;
  padding: var(--space-2) var(--space-4);
  background: var(--surface);
  border: var(--border-hair);
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-weight: var(--weight-semibold);
  text-decoration: none;
  transition: top var(--duration-fast) var(--ease);
}

.skip-link:focus { top: var(--space-2); }

/* --- Top navigation ------------------------------------------------------ */

.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--paper);
  border-bottom: var(--border-hair);
}

.nav__inner {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  height: var(--nav-height);
  max-width: var(--column-max-wide);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* The logo, then the name beside it, centred on one line. The name keeps
   the wordmark's type; the logo takes its size from the markup. */
.nav__wordmark {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight);
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}

.nav__logo {
  display: block;
  flex-shrink: 0;
}

.nav__links {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  height: 100%;
}

/* Current page takes a 2px accent underline, not a filled pill. */
.nav__link {
  display: inline-flex;
  align-items: center;
  height: 100%;
  padding: 0 var(--space-3);
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-weight: var(--weight-medium);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease);
}

@media (hover: hover) {
  .nav__link:hover { color: var(--ink); }
}

.nav__link[aria-current="page"] {
  border-bottom-color: var(--accent);
  color: var(--ink);
  font-weight: var(--weight-semibold);
}

/* Equal columns rather than flex, so both actions take the width of the
   wider label instead of shrinking to their own text. */
.nav__actions {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}

.nav .nav__toggle { display: none; }

/* Logged out — and while the session is still being checked — every
   destination but logging in needs an account, so the nav is the wordmark
   alone. Specific enough to beat an open phone menu. */
body[data-auth="out"] .nav__links,
body[data-auth="out"] .nav__actions,
body[data-auth="pending"] .nav__links,
body[data-auth="pending"] .nav__actions { display: none; }

/* Log out lives beside Add survey on a wide screen. On a narrow one the
   row has room for only Add survey and the menu toggle, so it moves to the
   foot of the menu. */
.nav .nav__logout-menu { display: none; }

/* On a touch screen the wordmark is a 44px target like everything else in
   the bar, wide as well as tall, since a phone shows the logo alone. The
   two actions sit 12px apart — Apple's spacing between bezelled controls —
   so a thumb aimed at Menu does not land on Add survey. */
@media (pointer: coarse) {
  .nav__wordmark {
    min-width: var(--target-min);
    min-height: var(--target-min);
  }

  .nav__actions { gap: var(--space-3); }
}

/* --- Content column ------------------------------------------------------ */

.column {
  max-width: var(--column-max);
  margin: 0 auto;
  padding: var(--space-6) var(--gutter) var(--space-7);
}

/* #/compare opts in — the comparison table earns the extra width. */
.column--wide { max-width: var(--column-max-wide); }

/* --- Page header ---------------------------------------------------------
   Title and its actions. No eyebrow label above it: the title says what
   the page is, and a label above would only repeat it. */

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.page-head__text { min-width: 0; }

/* A title with a control that belongs to it, like the survey form's ?. */
.page-head__title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.page-head__lede {
  margin-top: var(--space-2);
  color: var(--muted);
}

.page-head__actions {
  display: flex;
  flex-shrink: 0;
  gap: var(--space-2);
}

@media (pointer: coarse) {
  .page-head__actions { gap: var(--space-3); }
}

/* --- Sections ------------------------------------------------------------ */

.section + .section { margin-top: var(--space-6); }

.section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: var(--border-hair);
}

/* --- Grids --------------------------------------------------------------- */

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-4);
}

.grid-split {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-5);
}

/* The dashboard's panels sit 24px under the hero, or under the empty state
   that replaces it: the same step as under the page head and between the
   panels. Neither is a .section, so `.section + .section` never applied and
   the two touched. */
.hero + .grid-split,
.empty + .grid-split { margin-top: var(--space-5); }

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* --- Breakpoints --------------------------------------------------------- */

/* Nav collapses; two-column layouts stack. */
@media (max-width: 900px) {
  .nav__links {
    display: none;
    position: absolute;
    /* Directly under the header, whatever its height. */
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    height: auto;
    padding: var(--space-2) var(--gutter) var(--space-4);
    background: var(--paper);
    border-bottom: var(--border-hair);
  }

  .nav__links[data-open="true"] { display: flex; }

  .nav__link {
    height: auto;
    padding: var(--space-3) 0;
    border-bottom: none;
    border-left: 2px solid transparent;
    padding-left: var(--space-3);
  }

  .nav__link[aria-current="page"] {
    border-bottom-color: transparent;
    border-left-color: var(--accent);
  }

  /* The toggle is an icon, so each action takes its own width rather than
     an equal share of the row. */
  .nav__actions { grid-auto-columns: auto; }

  /* A square as tall as the button beside it: 40px is .btn's min-height.
     aria-label keeps its name, Menu. */
  .nav .nav__toggle {
    display: inline-flex;
    order: 3;
    min-width: 40px;
    padding: var(--space-2);
  }

  /* While the menu is open the toggle holds its pressed look, so the icon
     that opened the menu reads as the one that closes it. */
  .nav .nav__toggle[aria-expanded="true"] {
    background: var(--accent-tint);
    border-color: var(--accent);
    color: var(--accent);
  }

  .nav .nav__logout { display: none; }
  .nav .nav__logout-menu { display: flex; }

  .grid-split { grid-template-columns: 1fr; }
}

/* After the block above, so the touch size wins over its 40px. */
@media (max-width: 900px) and (pointer: coarse) {
  .nav .nav__toggle { min-width: var(--target-min); }
}

/* Phones keep one row: the logo, Add survey and the menu icon. The buttons
   never shrink. */
@media (max-width: 500px) {
  .nav__inner { gap: var(--space-3); }

  .nav__actions .btn--primary { padding-inline: var(--space-3); }
}

/* Below 360px the row is 288px wide at most, and the gap before the buttons
   closes to 8px. The 12px between the two buttons stays, so a thumb aimed
   at one does not land on the other. */
@media (max-width: 359px) {
  .nav__inner { gap: var(--space-2); }
}

/* A phone shows the logo alone. The name stays in the link, hidden as
   .visually-hidden hides it, so the link is still read as RoomCompare. */
@media (max-width: 640px) {
  .nav__wordmark-text {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

@media (max-width: 640px) {
  :root { --gutter: var(--gutter-narrow); }

  .column { padding-top: var(--space-5); }

  .page-head {
    flex-direction: column;
    align-items: stretch;
  }

  .page-head__actions > * { flex: 1; }
}
