/*
  Portland Fir — Base layer
  Reset, typography, focus-visible, and layout primitives (stack, cluster,
  grid, app shell). Import order: tokens.css, base.css, components.css.
*/

/* ---------------- Reset ---------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* The page itself never scrolls (iPad Safari keyboard finding): .pf-app__main
   below is the one scroll container, like a native app, so the on-screen
   keyboard resizing the visual viewport can't reveal a scrollable gap
   under/around the fixed app shell. Sheets/modals scroll their own body
   (.pf-modal__body etc.), which is unaffected by this. */
html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-ink);
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

img,
svg {
  display: block;
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

h1, h2, h3, h4, p {
  margin: 0;
}

a {
  color: var(--color-primary);
}

/* Controls that happen to be an <a> (buttons, segmented links) must never
   render underlined — only real inline text links should. Keep this list
   in sync with any new pf-* control class applied to an <a>;
   :focus-visible above still applies to these. */
a.pf-btn,
a[class^="pf-btn "],
a[class*=" pf-btn"],
a.pf-segmented__btn {
  text-decoration: none;
}

/* Numbers used for money/qty should not jitter as digits change */
.numeric,
.pf-line-card__total,
.pf-totals__value,
.pf-qty-stepper__value {
  font-variant-numeric: var(--font-variant-numeric);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* The hidden attribute must always win over component display rules
   (e.g. a hidden .pf-modal-scrim, which is display:flex). */
[hidden] {
  display: none !important;
}

.pf-visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------------- Typography scale ---------------- */

.text-xs { font-size: var(--font-size-xs); }
.text-sm { font-size: var(--font-size-sm); }
.text-md { font-size: var(--font-size-md); }
.text-lg { font-size: var(--font-size-lg); }
.text-xl { font-size: var(--font-size-xl); font-weight: var(--font-weight-semibold); line-height: var(--line-height-tight); }
.text-2xl { font-size: var(--font-size-2xl); font-weight: var(--font-weight-semibold); line-height: var(--line-height-tight); }
.text-3xl { font-size: var(--font-size-3xl); font-weight: var(--font-weight-bold); line-height: var(--line-height-tight); }

.text-muted { color: var(--color-ink-muted); }

/* ---------------- Focus ---------------- */

:focus {
  outline: none;
}

:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ---------------- Layout primitives ---------------- */

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

.stack--tight { gap: var(--space-2); }
.stack--loose { gap: var(--space-6); }

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

.cluster--between {
  justify-content: space-between;
}

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

.container {
  width: 100%;
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: var(--space-5);
}

.container--narrow { max-width: 880px; }

/* Full-bleed screens (login) that paint their own background. */
.pf-app__main.pf-app__main--bare { padding: 0; }

/* Screens whose content must fit the viewport, with inner panes that
   scroll on their own (the quote builder). */
.pf-app__main.pf-app__main--fixed {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ---------------- App shell ---------------- */

/* The shell is exactly one viewport tall: the app bar (and step bar)
   stay put and .pf-app__main is the scroll container, like a native
   iPad app. */
.pf-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  background: var(--color-bg);
}

.pf-app__main {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--space-5);
  padding-bottom: calc(var(--space-5) + var(--safe-bottom));
}

/* Two-pane layout for the quote builder in landscape; stacks in portrait */
.pf-two-pane {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-5);
  height: 100%;
}

@media (min-width: 820px) and (orientation: landscape) {
  .pf-two-pane {
    grid-template-columns: minmax(320px, 1fr) minmax(360px, 420px);
    align-items: start;
  }
}

@media (min-width: 1024px) {
  .container {
    padding-inline: var(--space-6);
  }
}

@media (min-width: 1366px) {
  .pf-two-pane {
    grid-template-columns: minmax(420px, 1fr) minmax(400px, 460px);
  }
}
