/*
 * Cruise Vacation Budget Worksheet, styles
 * Pairs with page-worksheet.php + assets/js/worksheet.js.
 *
 * Section-based, progressive-reveal layout. Uses the existing ff-* tokens
 * (color, radius, shadow) from tokens.css and global.css, no new design
 * language, just new composition primitives.
 */

.ff-worksheet__hero {
  padding-bottom: 32px;
}

.ff-worksheet__form {
  max-width: var(--ff-wide-width);
  margin: 0 auto;
  padding: 0 var(--ff-page-padding, 48px);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ── Section shell ─────────────────────────────── */
.ffw-section {
  background: #fff;
  border: 1px solid var(--ff-border);
  border-radius: var(--ff-radius);
  box-shadow: var(--ff-shadow-card);
  padding: 32px 32px 28px;
}

.ffw-section__head {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 16px;
  margin-bottom: 20px;
}
.ffw-section__ord {
  grid-row: 1 / 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--ff-teal);
  color: var(--ff-teal-dark);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.1em;
}
.ffw-section__title {
  grid-column: 2;
  margin: 0;
  font-size: 26px;
  line-height: 1.15;
  color: var(--ff-ocean);
  letter-spacing: -0.02em;
}
.ffw-section__lede {
  grid-column: 2;
  margin: 0;
  font-size: 16px;
  line-height: 1.55;
  color: var(--ff-muted);
}

/* ── Subsection inside Section A ──────────────── */
.ffw-subsection {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px dashed var(--ff-border);
}
.ffw-subsection__title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ff-stone);
  margin: 0 0 6px;
}
.ffw-subsection__hint {
  margin: 0 0 14px;
  font-size: 14px;
  color: var(--ff-muted);
  line-height: 1.5;
}

/* ── Grids ─────────────────────────────────────── */
.ffw-grid {
  display: grid;
  gap: 16px;
}
.ffw-grid--2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.ffw-grid--3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

/* ── Fields ────────────────────────────────────── */
.ffw-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ffw-field__label {
  font-size: 14px;
  font-weight: 700;
  color: var(--ff-navy);
}
.ffw-field__hint {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--ff-stone);
  letter-spacing: 0;
  margin-top: 2px;
}
.ffw-input {
  width: 100%;
  padding: 14px 14px;
  font-size: 16px;
  /* 16px prevents iOS Safari auto-zoom on focus. Do not drop below 16. */
  line-height: 1.35;
  min-height: 48px;
  border: 1px solid var(--ff-border);
  border-radius: var(--ff-radius-sm);
  background: #fff;
  color: var(--ff-navy);
  transition: border-color var(--ff-ease-fast), box-shadow var(--ff-ease-fast);
  font-family: inherit;
  /* iOS: clear the native chrome on selects + number inputs so size is ours */
  -webkit-appearance: none;
          appearance: none;
}
.ffw-input:focus {
  outline: none;
  border-color: var(--ff-ocean);
  box-shadow: 0 0 0 3px rgba(0, 99, 128, 0.15);
}
/* Select dropdowns need their own caret back after -webkit-appearance:none.
 * Extra right padding (42px) reserves enough room for the caret even when
 * the selected option text is long (e.g. "Wonder of the Seas"). Text also
 * gets ellipsis so very long values degrade cleanly instead of clipping
 * mid-character behind the caret. */
select.ffw-input {
  padding-right: 42px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ff-ocean) 50%),
                    linear-gradient(135deg, var(--ff-ocean) 50%, transparent 50%);
  background-position: calc(100% - 20px) 55%, calc(100% - 14px) 55%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}
/* Ensure the select doesn't inherit any parent `width: max-content` that
 * would try to fit the dropdown contents, and doesn't clip on narrow
 * container columns. */
.ffw-field > select.ffw-input { max-width: 100%; width: 100%; }
.ffw-input--currency::before { content: "$"; }
.ffw-field--inline {
  margin-top: 14px;
  max-width: 420px;
}

/* ── Package option cards ──────────────────────── */
.ffw-package-list {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  margin-bottom: 12px;
}
.ffw-pkg-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 18px;
  border: 1px solid var(--ff-border);
  border-radius: var(--ff-radius);
  background: var(--ff-sand-alt);
  cursor: pointer;
  transition: border-color var(--ff-ease-fast), background var(--ff-ease-fast);
}
.ffw-pkg-option:hover {
  border-color: var(--ff-ocean);
}
.ffw-pkg-option__input {
  margin-top: 3px;
  flex-shrink: 0;
  accent-color: var(--ff-ocean);
}
.ffw-pkg-option__body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1 1 auto;
}
.ffw-pkg-option__name {
  font-size: 16px;
  font-weight: 700;
  color: var(--ff-ocean);
}
.ffw-pkg-option__price {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--ff-coral);
  text-transform: uppercase;
}
.ffw-pkg-option__short {
  font-size: 14px;
  line-height: 1.5;
  color: var(--ff-muted);
}
.ffw-pkg-option__input:checked + .ffw-pkg-option__body .ffw-pkg-option__name {
  color: var(--ff-coral);
}
.ffw-pkg-option:has(.ffw-pkg-option__input:checked) {
  background: #fff;
  border-color: var(--ff-ocean);
  box-shadow: 0 0 0 3px rgba(0, 99, 128, 0.08);
}

/* ── Inline line rows (gratuity + wifi) ────────── */
.ffw-line {
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 16px;
  row-gap: 4px;
  align-items: center;
  padding: 14px 16px;
  background: var(--ff-sand-alt);
  border-radius: var(--ff-radius-sm);
}
.ffw-line__label {
  font-size: 15px;
  font-weight: 700;
  color: var(--ff-navy);
  grid-column: 1;
}
.ffw-line__detail {
  grid-column: 1;
  grid-row: 2;
  font-size: 13px;
  color: var(--ff-stone);
  line-height: 1.4;
}
.ffw-line__amount {
  grid-column: 2;
  grid-row: 1 / 3;
  align-self: center;
  font-size: 18px;
  font-weight: 800;
  color: var(--ff-navy);
  font-variant-numeric: tabular-nums;
}
.ffw-line__amount[data-covered="true"] {
  color: var(--ff-teal-dark);
}
.ffw-line__input {
  grid-column: 2;
  grid-row: 1 / 3;
  width: 140px;
  justify-self: end;
}

/* ── Dining section ────────────────────────────── */
.ffw-dining {
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.ffw-dining__empty {
  margin: 0;
  padding: 24px;
  background: var(--ff-sand-alt);
  border-radius: var(--ff-radius-sm);
  color: var(--ff-muted);
  font-size: 15px;
  text-align: center;
}
.ffw-dining__group {
  border: 1px solid var(--ff-border);
  border-radius: var(--ff-radius);
  padding: 20px 22px;
  background: #fff;
}
.ffw-dining__group--included { background: #f3fbf7; border-color: #b9e5d0; }
.ffw-dining__group--casual   { background: var(--ff-sand-alt); }
.ffw-dining__group--specialty{ background: #fff7f4; border-color: #f3c2b6; }

.ffw-dining__head {
  margin-bottom: 14px;
}
.ffw-dining__title {
  font-size: 18px;
  margin: 0 0 4px;
  color: var(--ff-ocean);
  letter-spacing: -0.01em;
}
.ffw-dining__lede {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ff-muted);
}
.ffw-dining__list {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
}
.ffw-venue {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px 20px;
  align-items: center;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--ff-border);
  border-radius: var(--ff-radius-sm);
}
.ffw-venue__info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.ffw-venue__name {
  font-size: 16px;
  font-weight: 700;
  color: var(--ff-navy);
}
.ffw-venue__cuisine {
  font-size: 13px;
  color: var(--ff-teal-dark);
  font-weight: 600;
}
.ffw-venue__price {
  font-size: 13px;
  color: var(--ff-stone);
  line-height: 1.45;
}
.ffw-venue__qty {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.ffw-venue__qty-label {
  color: var(--ff-stone);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.ffw-venue__qty-input {
  width: 84px;
  text-align: center;
  /* Ensure the "Meals planned" number input stays touch-friendly
   * even when the venue row stacks tight on mobile. */
  min-height: 48px;
}

/* ── Expandable sections (Section C + D) ───────── */
.ffw-expand {
  padding: 0;
  overflow: hidden;
}
.ffw-expand__summary {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 24px 32px;
  cursor: pointer;
  list-style: none;
}
.ffw-expand__summary::-webkit-details-marker { display: none; }
.ffw-expand__summary::marker { content: ""; }
.ffw-expand__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ffw-expand__title {
  font-size: 20px;
  font-weight: 700;
  color: var(--ff-ocean);
}
.ffw-expand__hint {
  font-size: 14px;
  color: var(--ff-muted);
  line-height: 1.45;
}
.ffw-expand__chev {
  font-size: 22px;
  color: var(--ff-ocean);
  transition: transform var(--ff-ease-fast);
}
.ffw-expand[open] .ffw-expand__chev { transform: rotate(180deg); }
.ffw-expand__body {
  padding: 4px 32px 28px;
  border-top: 1px dashed var(--ff-border);
}
.ffw-expand__microcopy {
  margin: 16px 0 0;
  font-size: 13px;
  color: var(--ff-stone);
  line-height: 1.5;
}

/* ── Summary (Section E) ───────────────────────── */
.ffw-summary {
  background: linear-gradient(180deg, #fff, var(--ff-sand-alt));
  border-color: var(--ff-ocean);
}
.ffw-summary__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}
.ffw-summary__main {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ffw-summary__label {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ff-coral);
}
.ffw-summary__amount {
  font-size: 56px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--ff-ocean);
  font-variant-numeric: tabular-nums;
}
.ffw-summary__sub {
  font-size: 14px;
  color: var(--ff-muted);
  line-height: 1.5;
  margin-top: 4px;
}
.ffw-summary__sub strong {
  color: var(--ff-navy);
  font-variant-numeric: tabular-nums;
}

.ffw-summary__breakdown {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ffw-summary__breakdown li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  padding: 8px 12px;
  background: #fff;
  border: 1px solid var(--ff-border);
  border-radius: var(--ff-radius-sm);
  font-size: 14px;
}
.ffw-summary__breakdown li span {
  color: var(--ff-muted);
}
.ffw-summary__breakdown li strong {
  color: var(--ff-navy);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.ffw-summary__notes {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ffw-note {
  margin: 0;
  padding: 12px 14px;
  background: #fff6ec;
  border: 1px solid rgba(154, 61, 46, 0.25);
  border-left: 4px solid var(--ff-coral);
  border-radius: var(--ff-radius-sm);
  font-size: 14px;
  line-height: 1.55;
  color: var(--ff-navy);
}

/* ── Export (Section F) ────────────────────────── */
.ffw-export__row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}
.ffw-export__row .ffw-field {
  flex: 1 1 220px;
  min-width: 200px;
}
.ffw-export__row .ffh-btn {
  flex: 0 0 auto;
  margin-top: 0;
}
.ffw-export__microcopy {
  margin: 14px 0 0;
  font-size: 13px;
  color: var(--ff-stone);
}

/* ── Print-only ──────────────────────────────────
   Bulletproof print isolation:
   (1) @page gives us tight, known margins so the print area is predictable.
   (2) `body.ffw-printing > *` is display:none, which kills BOTH the visual
       and the layout flow that was generating blank trailing pages. The old
       `visibility: hidden` approach left the hidden body in normal flow, so
       tall hidden content pushed the print-only block past page 1 and
       produced empty pages after.
   (3) The ffw-print-only container is removed from its absolute positioning
       during print so it's the only in-flow block, one clean page. */
.ffw-print-only { display: none; }
@media print {
  @page { size: auto; margin: 14mm 16mm; }
  html, body { background: #fff !important; }
  body.ffw-printing > *:not(.ffw-print-only) { display: none !important; }
  .ffw-print-only {
    display: block;
    position: static;
    padding: 0;
    background: #fff;
    color: #000;
  }
  .ffw-print { font-family: "Plus Jakarta Sans", system-ui, sans-serif; page-break-inside: avoid; }
  .ffw-print__head {
    border-bottom: 2px solid #006380;
    padding-bottom: 12px;
    margin-bottom: 14px;
  }
  .ffw-print__brand {
    display: block;
    font-size: 11px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: #9a3d2e;
    font-weight: 800;
  }
  .ffw-print__head h1 {
    font-size: 24px;
    margin: 4px 0 2px;
    color: #006380;
  }
  .ffw-print__head p { font-size: 11px; color: #57534e; margin: 0; }
  .ffw-print__meta p { font-size: 13px; margin: 2px 0; }
  .ffw-print__total h2,
  .ffw-print__breakdown h2 {
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #9a3d2e;
    margin: 14px 0 6px;
  }
  .ffw-print__big { font-size: 36px; font-weight: 800; color: #006380; margin: 0; line-height: 1; }
  .ffw-print__breakdown dl {
    margin: 0;
    display: grid;
    grid-template-columns: 1fr auto;
    column-gap: 16px;
    row-gap: 4px;
  }
  .ffw-print__breakdown dt { font-weight: 400; font-size: 12px; }
  .ffw-print__breakdown dd { margin: 0; font-weight: 800; font-variant-numeric: tabular-nums; font-size: 12px; }
  .ffw-print__foot {
    margin-top: 20px;
    padding-top: 10px;
    border-top: 1px solid #ddd;
    font-size: 10px;
    color: #57534e;
  }
  /* Hide the sticky total bar during print */
  .ffw-sticky-total { display: none !important; }
}

/* ── Sticky running total ────────────────────────
   Always visible while on the worksheet. Docked to the viewport bottom
   on every viewport size. The full summary in Section E is complementary:
   it provides the detailed breakdown while the sticky bar keeps the top-
   line number visible no matter where the user has scrolled. Previous
   auto-hide behavior removed per user feedback, the running total was
   meant to stay glued, and hiding it when near the full summary defeated
   the point. */
.ffw-sticky-total {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 30;
  background: var(--ff-ocean);
  color: #fff;
  box-shadow: 0 -8px 24px rgba(0, 99, 128, 0.25);
  /* iOS: respect home-indicator area with env() safe-area inset */
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.ffw-sticky-total__inner {
  max-width: var(--ff-wide-width);
  margin: 0 auto;
  padding: 10px clamp(16px, 4vw, 28px);
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 16px 20px;
  align-items: center;
}
.ffw-sticky-total__col {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}
.ffw-sticky-total__lbl {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.7);
  line-height: 1.2;
}
.ffw-sticky-total__val {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  color: #fff;
}
.ffw-sticky-total__col--sub .ffw-sticky-total__val {
  font-size: 16px;
  color: rgba(255, 255, 255, 0.88);
}
.ffw-sticky-total__jump {
  justify-self: end;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: var(--ff-radius-pill);
  white-space: nowrap;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.ffw-sticky-total__jump:hover,
.ffw-sticky-total__jump:focus {
  background: rgba(255, 255, 255, 0.12);
}

/* Give the form a bottom-pad so the sticky bar doesn't cover the
   last section's buttons. Sized for the ~64px sticky-bar height. */
.ff-worksheet__form { padding-bottom: 96px; }

@media (max-width: 640px) {
  .ffw-sticky-total__inner {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 6px 12px;
    padding: 10px 16px;
  }
  .ffw-sticky-total__jump {
    grid-column: 1 / 3;
    justify-self: center;
    font-size: 12px;
    padding: 8px 12px;
    min-height: 38px;
  }
  .ffw-sticky-total__val { font-size: 18px; }
  .ffw-sticky-total__col--sub .ffw-sticky-total__val { font-size: 14px; }
}

/* ── Responsive ────────────────────────────────── */
@media (max-width: 900px) {
  .ff-worksheet__form { padding: 0 24px; }
  .ffw-section { padding: 24px 20px 20px; }
  .ffw-expand__summary { padding: 20px 20px; }
  .ffw-expand__body { padding: 4px 20px 20px; }
  .ffw-summary__grid { grid-template-columns: 1fr; gap: 20px; }
  .ffw-summary__amount { font-size: 44px; }
  .ffw-venue {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .ffw-venue__qty { justify-content: flex-end; }
}
