/*
  Houston Coffee Office Wi‑Fi Portal (Desktop-first, fully responsive)
  Goal:
  - ONE layout that adapts to: iPad, captive portal popups (macOS CNA), iOS/Android webviews, small windows.
  - No separate “phone design” overrides.
  - Avoid vertical scrolling for critical actions by making the container fit small heights.

  Notes:
  - Captive portals on macOS are often short and non-resizable; we treat small HEIGHT as primary constraint.
  - We do NOT “switch to a different layout”; we scale down gracefully and stack only when necessary.
*/

:root {
  --coffee-950: #0b0705;
  --coffee-900: #120b08;
  --coffee-700: #2a1711;
  --cream: #fff7ed;
  --paper: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --stroke: rgba(15, 23, 42, 0.08);
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.18);
  --shadow-soft: 0 10px 24px rgba(15, 23, 42, 0.12);
  --radius: 18px;
  --accent: #9a5612;
  --accent-soft: #fef3c7;

  /* Fluid sizing helpers (keeps same layout, just scales down) */
  --box-max: 700px;
  --pad: clamp(8px, 1.8vmin, 18px);
  --gap: clamp(8px, 1.8vmin, 18px);

  --title: clamp(18px, 2.2vw, 28px);
  --price: clamp(14px, 1.6vw, 18px);
  --desc: clamp(12px, 1.2vw, 14px);
  --btn: clamp(13px, 1.2vw, 15px);
  --logo: clamp(56px, 10vmin, 120px);
}

* { box-sizing: border-box; }

html, body {
  height: auto;
  min-height: 100%;
}

body,
body.wifi-page {
  font-optical-sizing: auto;
  font-style: normal;
  font-variation-settings: "wdth" 100;
  font-family: -apple-system, Roboto, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);

  /* Popup-friendly layout */
  min-height: 100dvh;
  display: grid;
  place-items: center;

  /* Safe-area padding (iOS) + responsive padding */
  padding:
    max(var(--pad), env(safe-area-inset-top))
    max(var(--pad), env(safe-area-inset-right))
    max(var(--pad), env(safe-area-inset-bottom))
    max(var(--pad), env(safe-area-inset-left));

  /* Keep the page stable in webviews */
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;

  background-color: #f8f5f2;
}

/* Backgrounds (keep your existing assets) */
@media (min-width: 720px) {
  body {
    background-image: var(--wifi-background-desktop, radial-gradient(circle at top, rgba(255,255,255,0.12), rgba(0,0,0,0))), linear-gradient(180deg, color-mix(in srgb, var(--wifi-secondary, #fff7ed) 65%, white), #f8f5f2);
    background-position: center top;
    background-size: cover;
    background-repeat: no-repeat;
    background-attachment: fixed;
  }
}

@media (max-width: 719px) {
  body {
    background-image: var(--wifi-background-mobile, radial-gradient(circle at top, rgba(255,255,255,0.12), rgba(0,0,0,0))), linear-gradient(180deg, color-mix(in srgb, var(--wifi-secondary, #fff7ed) 65%, white), #f8f5f2);
    background-position: center top;
    background-size: cover;
    background-repeat: no-repeat;
    background-attachment: scroll;
  }
}

/* ===== Outer container ===== */
.box:not(.boxmain) {
  width: 100%;
  max-width: var(--box-max);

  max-height: calc(100dvh - (var(--pad) * 2));
  overflow: auto;
  -webkit-overflow-scrolling: touch;

  background: rgba(255, 255, 255, 0.96);
  padding: var(--pad);
  border-radius: 20px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: var(--shadow);

  /* Enables container queries */
  container-type: inline-size;

  /* Scaling variable (used to fit everything in captive portal popups) */
  --portal-scale: 1;

  /* Make sure scaled content can center nicely */
  display: grid;
  place-items: start center;
}
#packageBox:not(.hidden){
    padding:20px;
    border-radius:10px;
    background:#fff;
}
.boxMain {
  width: 100%;
  max-width: var(--box-max);

  max-height: calc(100dvh - (var(--pad) * 2));
  overflow: auto;
  -webkit-overflow-scrolling: touch;

  /* Enables container queries */
  container-type: inline-size;

  /* Scaling variable (used to fit everything in captive portal popups) */
  --portal-scale: 1;

  /* Make sure scaled content can center nicely */
  display: grid;
  place-items: start center;
}

/*
  IMPORTANT:
  If you want true “fit-to-window” with NO scroll in short captive portal popups,
  wrap your page content INSIDE .box with:
    <div class="box-scale"> ...existing content... </div>
  This allows safe scaling without breaking fixed-position modals.
*/
.box-scale {
  transform: scale(var(--portal-scale));
  transform-origin: top center;
}

/*
  Elastic fit (NO scroll) for captive portal popups / short windows
  Requires wrapping inner content with:
    <div class="box-scale"> ... </div>
*/
@media (max-height: 720px), (max-width: 860px) {
  .box {
    /* remove inner scrollbars; scale instead */
    overflow: auto;

    /* Reduce padding a bit so we gain vertical room */
    padding: clamp(6px, 1.4vmin, 14px);

    /* Scale based on BOTH height and width, whichever is tighter */
    --portal-scale: min(
      1,
      calc((100dvh - (clamp(6px, 1.4vmin, 14px) * 2)) / 860),
      calc((100dvw - (clamp(6px, 1.4vmin, 14px) * 2)) / 980)
    );
  }
}

@media (max-height: 600px) {
  .box {
    --portal-scale: min(
      1,
      calc((100dvh - (clamp(6px, 1.4vmin, 14px) * 2)) / 980),
      calc((100dvw - (clamp(6px, 1.4vmin, 14px) * 2)) / 980)
    );
  }
}

@media (max-height: 520px) {
  .box {
    --portal-scale: min(
      1,
      calc((100dvh - (clamp(6px, 1.4vmin, 14px) * 2)) / 1120),
      calc((100dvw - (clamp(6px, 1.4vmin, 14px) * 2)) / 980)
    );
  }
}
h1 {
  font-family: "Roboto", sans-serif;
  font-size: clamp(20px, 2.1vw, 24px);
  margin: 0;
  letter-spacing: 0.2px;
}

.subtitle {
  color: var(--muted);
  margin: 6px 0 18px;
  font-size: clamp(12px, 1.2vw, 14px);
  line-height: 1.45;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0 18px;
}

.btn-access {
  color: #d27d14;
  text-decoration: underline;
  margin-top: 0px;
  padding-top: 0px;
  background: #fff;
  border: none;
  box-shadow: none;
  line-height: 1.1;
  cursor: pointer;
  font-size: clamp(12px, 1.1vw, 13px);
}

.btn-access:hover { opacity: 0.95; }

/* ===== Plan grid =====
   Default stays 2 columns.
   If the container gets narrow (small popup / iPad split view), stack.
*/
.plan-grid {
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  justify-content: center;
  align-items: stretch;
}
.plan-grid.single-mode {
  grid-template-columns: minmax(280px, 460px);
}

/* Stack only if container is very narrow */
@container (max-width: 600px) {
  .plan-grid {
    grid-template-columns: 1fr;
  }
}

/* === HEIGHT-CONSTRAINED MODE (macOS captive portal fix) === */
@media (max-height: 620px) {
  .box {
    padding: 12px;
  }

  .plan-card {
    padding: 14px;
    gap: 8px;
  }

  .plan-logo {
    width: 72px;
    height: 72px;
  }

  .plan-title {
    font-size: 18px;
  }

  .plan-package-desc {
    font-size: 14px;
  }

  .plan-desc {
    font-size: 12px;
    -webkit-line-clamp: 1;
  }

  .btn {
    margin-top: 8px;
    padding: 10px 12px;
    font-size: 13px;
  }

  /* Terms + consent must NEVER push layout */
  .note {
    margin-top: 8px;
    padding: 8px 10px;
    font-size: 12px;
    line-height: 1.4;
  }

  .wifi-consent {
    margin-top: 6px;
    font-size: 11px;
  }
}

@container (max-width: 640px) {
  .plan-grid {
    grid-template-columns: 1fr;
  }
}

/* Also stack if HEIGHT is very small (macOS captive portal window) */
@media (max-height: 520px) {
  .plan-grid {
    grid-template-columns: 1fr;
  }
}

.plan-card {
  position: relative;
  padding: clamp(14px, 2.4vw, 24px);
  border-radius: var(--radius);
  border: 1px solid var(--stroke);
  background: var(--paper);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1.4vw, 12px);
  align-items: center;
  text-align: center;
  width: 100%;
  min-width: 0;
}

.plan-card.premium {
  border-color: rgba(154, 52, 18, 0.2);
  box-shadow: 0 24px 48px rgba(154, 52, 18, 0.18);
}

.plan-logo {
  width: var(--logo);
  height: var(--logo);
  border-radius: 50%;
  padding: clamp(6px, 1.2vw, 10px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--accent);
  font-size: 18px;
  overflow: hidden;
  border: 1px solid #efefef;
  background: #fff;
}

.plan-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.plan-title {
  font-family: "Roboto", sans-serif;
  font-size: var(--title);
  font-weight: 800;
  margin: 6px 0 0;
}

.plan-package-desc {
  font-size: var(--price);
  font-weight: 400;
  color: var(--text);
  margin: 0;
}

.plan-desc {
  font-size: var(--desc);
  color: var(--muted);
  margin: 0;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* In short height popups, allow a bit more text truncation to keep buttons visible */
@media (max-height: 520px) {
  .plan-desc { -webkit-line-clamp: 1; }
}

/* ===== Info popover ===== */
.info-popover {
  position: relative;
  align-self: flex-end;
}

.info-trigger {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: #fff;
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
}

.info-panel {
  position: absolute;
  top: 32px;
  right: -4px;
  width: min(260px, calc(100cqw - 20px));
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 5;
  text-align: left;
}

.info-title {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--text);
}

.info-panel ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.info-panel li::before {
  content: "•";
  margin-right: 6px;
  color: var(--accent);
}

.info-popover:hover .info-panel,
.info-popover.is-open .info-panel,
.info-trigger:focus + .info-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* ===== Buttons & inputs ===== */
.btn {
  width: 100%;
  padding: clamp(10px, 1.4vw, 12px) clamp(10px, 1.6vw, 14px);
  margin-top: 12px;
  font-size: var(--btn);
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.18s ease, opacity 0.18s ease, background 0.18s ease;
  box-shadow: var(--shadow-soft);
}

.btn:active { transform: translateY(1px); }
.btn:hover { opacity: 0.96; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: #111827; color: #fff; }

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid rgba(15, 23, 42, 0.16);
  box-shadow: none;
}

.btn-primary2 {
  background: linear-gradient(180deg, #fde68a, #fdba74);
  color: #7c2d12;
  border: 1px solid rgba(120, 53, 15, 0.12);
}

.btn-link {
  display: inline-block;
  margin-top: 8px;
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
}

.btn-link:hover { text-decoration: underline; }

.input {
  width: 100%;
  padding: 11px 12px;
  margin-top: 10px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: #fff;
  color: var(--text);
  font-size: 14px;
  outline: none;
}

.input::placeholder { color: rgba(15, 23, 42, 0.5); }

.input:focus {
  border-color: rgba(154, 52, 18, 0.4);
  box-shadow: 0 0 0 4px rgba(253, 186, 116, 0.25);
}

/* ===== Forms / notes ===== */
.form-wrap {
  width: 100%;
  margin: 0 auto;
  background: #fff;
  padding: clamp(16px, 2.2vw, 22px);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--stroke);
}

.note {
  margin-top: 14px;
  padding: 12px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(15, 23, 42, 0.08);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.global-consent-note {
  margin-top: 18px;
}
.global-consent-note .wifi-consent {
  justify-content: center;
}


.note b { color: var(--text); }
.note a { color: var(--accent); }

.error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #b91c1c;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
  margin-bottom: 12px;
}

.hidden { display: none; }

.divider {
  margin: 18px 0;
  border-top: 1px solid rgba(15, 23, 42, 0.1);
}

.meta {
  font-size: 12px;
  color: rgba(15, 23, 42, 0.55);
  line-height: 1.45;
}

/* ===== Packages ===== */
.package-grid {
  display: grid;
  gap: 14px;
}

@media (min-width: 720px) {
  .package-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@container (max-width: 640px) {
  .package-grid { grid-template-columns: 1fr; }
}

.package-panel {
  padding: 16px;
  border-radius: 16px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-soft);
}

.hour-stepper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stepper-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(15, 23, 42, 0.2);
  background: #fff;
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
}

.stepper-input {
  width: 72px;
  text-align: center;
  font-size: 16px;
  border-radius: 10px;
  border: 1px solid rgba(15, 23, 42, 0.2);
  background: #fff;
  color: var(--text);
  padding: 8px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: rgba(15, 23, 42, 0.75);
  gap: 10px;
}

.summary-row strong { color: var(--text); }
.summary-row input { margin-right: 8px; }

/* ===== Modals ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 22px 14px;
  background: color-mix(in srgb, var(--wifi-primary, #111827) 28%, transparent);
  z-index: 9999;
}

.modal-card {
  width: 100%;
  max-width: 520px;
  border-radius: 18px;
  background: color-mix(in srgb, #ffffff 90%, white); 
  border: 1px solid color-mix(in srgb,#111827 16%, white);
  box-shadow: 0 18px 55px rgba(15, 23, 42, 0.25);
  overflow: hidden;
  color:#000;
}

/* In short-height captive portal windows, slightly reduce modal max width */
@media (max-height: 520px) {
  .modal-card { max-width: 480px; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid color-mix(in srgb, var(--wifi-primary, #111827) 14%, white);
}

.modal-header h3 {
  margin: 0;
  font-size: 16px;
}

.modal-close {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--wifi-primary, #111827) 20%, white);
  background: color-mix(in srgb, var(--wifi-secondary, #fff) 82%, white);
  color: var(--text);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.modal-body {
  padding: 14px 16px;
  color: color-mix(in srgb, var(--text) 90%, white);
  font-size: 13px;
  line-height: 1.55;

  /* Scroll inside modal only, not whole page */
  max-height: min(70dvh, 520px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-body::-webkit-scrollbar { width: 10px; }

.modal-body::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--wifi-primary, #111827) 25%, white);
  border-radius: 999px;
}

.modal-body::-webkit-scrollbar-track {
  background: color-mix(in srgb, var(--wifi-secondary, #fff) 85%, white);
}

.modal-footer {
  padding: 14px 16px 16px;
  border-top: 1px solid color-mix(in srgb, var(--wifi-primary, #111827) 14%, white);
}

#wifiTermsLink,
#openTerms {
  color: var(--wifi-accent);
  text-decoration: underline;
}

.wifi-consent {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
  text-align: center;
  flex-wrap: wrap;
}

.wifi-consent span { display: inline-block; }

.wifi-consent input {
  margin-top: 2px;
  accent-color: var(--accent);
}

.wifi-consent a {
  color: var(--accent);
  text-decoration: underline;
}

.member-in-title {
  font-size: clamp(16px, 1.8vw, 18px);
}

.member-in-description {
  font-size: clamp(12px, 1.4vw, 14px);
}

@supports (-webkit-touch-callout: none) {
  body { background-attachment: scroll !important; }
}

/* Popover alignment hardening */
.info-popover { position: relative; z-index: 30; }
.info-trigger { position: relative; z-index: 2; }
.info-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  max-width: min(320px, calc(100vw - 24px));
  padding: 12px;
  border-radius: 12px;
  background: #fff;
  color: #1f2937;
  border: 1px solid rgba(15, 23, 42, 0.12);
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.2);
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity .15s ease, transform .15s ease;
}
.info-popover.is-open .info-panel { opacity: 1; pointer-events: auto; transform: translateY(0); }
