/* ======================================================
   Home Captain · Responsive Polish Pass
   Cross-device tuning: phone → tablet → desktop
   Owns: breakpoint overrides, tap targets, motion reduction
   Does NOT own: base layout, palette, component definitions
   ====================================================== */

/* ========================
   TYPOGRAPHY — clamp() scales
   ======================== */

/* Section-level serif headlines */
.proto-integrations-title {
  font-size: clamp(1.05rem, 2.5vw, 1.35rem);
}

.proto-pw-step-title {
  font-size: clamp(1rem, 2.2vw, 1.1rem);
}

.proto-role-banner-name {
  font-size: clamp(1rem, 2.5vw, 1.2rem);
}

.proto-role-stat-value {
  font-size: clamp(1.3rem, 3vw, 1.6rem);
}

/* ========================
   DESKTOP — generous whitespace, max-width cap
   ======================== */

@media (min-width: 1280px) {
  .proto-main {
    max-width: 1200px;
    padding: 40px 48px;
  }

  /* Keep header inner at 1200px too */
  .proto-header-inner {
    max-width: 1200px;
    padding: 0 48px;
  }

  .proto-footer-inner {
    max-width: 1200px;
  }
}

/* ========================
   TABLET — 768px–1024px
   2-up grids, readable layouts
   ======================== */

@media (min-width: 768px) and (max-width: 1024px) {
  /* Vault: 2-col on tablet */
  .proto-vault-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Integrations: 2-col on tablet, not waiting for 900px collapse */
  .proto-integrations-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }

  /* Privacy walkthrough views: 2-col on tablet */
  .proto-pw-views {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Role banner — keep stats visible on tablet */
  .proto-role-banner-stats {
    display: flex;
  }
}

/* ========================
   PHONE — up to 767px
   Single column, scroll chips, full-screen modal
   ======================== */

@media (max-width: 767px) {

  /* --- Header --- */
  .proto-header-inner {
    padding: 0 12px;
    gap: 8px;
  }

  /* Logo: hide text on very small phones */
  .proto-logo-text {
    display: none;
  }

  /* Role switcher → horizontal scroll strip */
  .proto-role-switcher {
    flex: 1;
    overflow-x: auto;
    overflow-y: hidden;
    justify-content: flex-start;
    gap: 6px;
    /* smooth momentum scroll on iOS */
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    /* hide scrollbar visually while preserving function */
    scrollbar-width: none;
    padding: 4px 0;
  }

  .proto-role-switcher::-webkit-scrollbar {
    display: none;
  }

  /* Pills: fixed min-height 44px for touch targets */
  .proto-role-pill {
    flex-shrink: 0;
    min-height: 44px;
    padding: 0 14px;
    scroll-snap-align: start;
    /* show labels again since pills scroll horizontally — icon + short label fits */
    display: flex;
    align-items: center;
  }

  /* Show labels on scroll strip (override the 768px hide rule in polish.css) */
  .proto-role-label {
    display: inline !important;
    font-size: 0.78rem;
  }

  /* Persona chip: icon-only on phone */
  .proto-persona-name {
    display: none;
  }

  /* --- Main layout --- */
  .proto-main {
    padding: 16px;
  }

  /* --- Role banner --- */
  .proto-role-banner-stats {
    display: none;
  }

  .proto-role-banner-inner {
    padding: 14px 16px;
    gap: 12px;
  }

  .proto-role-banner-icon {
    width: 42px;
    height: 42px;
    font-size: 1.3rem;
  }

  /* --- Task section --- */

  /* Task filter chips: scrollable row on phone */
  .proto-task-filter {
    display: flex !important; /* override the 480px hide */
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 6px;
    padding-bottom: 4px;
  }

  .proto-task-filter::-webkit-scrollbar {
    display: none;
  }

  .proto-filter-pill {
    flex-shrink: 0;
    min-height: 44px;
    padding: 0 14px;
    display: flex;
    align-items: center;
  }

  /* Task check circles — wrap them in the item's already-generous padding */
  .proto-task-check {
    width: 24px;
    height: 24px;
    /* Use margin to center within the taller item row */
    margin-top: 0;
    flex-shrink: 0;
  }

  /* Task item: more vertical breathing room */
  .proto-task-item {
    padding: 14px 16px;
    gap: 10px;
  }

  /* --- Vault --- */
  .proto-vault-grid {
    grid-template-columns: 1fr;
  }

  /* Vault toggle rows: expand tap area to 44px without visual change */
  .proto-vault-toggle-row {
    /* Extra vertical padding so the whole row is tap-friendly */
    padding: 4px 0;
  }

  /* --- Privacy walkthrough --- */

  .proto-pw-progress-bar {
    padding: 16px 16px 0;
  }

  .proto-pw-step {
    padding: 16px 16px 8px;
  }

  .proto-pw-nav {
    padding: 14px 16px 16px;
  }

  /* Step 0: vault enter — stack vertically on tiny screens */
  .proto-pw-vault-enter {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .proto-pw-arrow {
    transform: rotate(90deg);
  }

  .proto-pw-vault-box {
    width: 100%;
    height: 72px;
  }

  /* Step 1: permission badges — full width */
  .proto-pw-perm-badge {
    min-width: unset;
    flex: 1;
  }

  /* Step 2: role views — single column */
  .proto-pw-views {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  /* Walkthrough nav buttons — ensure 44px min height */
  .proto-pw-nav-btn {
    min-height: 44px;
    padding: 0 20px;
  }

  /* --- Task creation modal: full-screen on mobile --- */
  .proto-modal-overlay {
    padding: 0;
    align-items: flex-end; /* sheet from bottom */
  }

  .proto-modal {
    max-width: 100%;
    width: 100%;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    /* Allow scrolling inside modal */
    max-height: 92vh;
    overflow-y: auto;
  }

  /* Modal form row: single col on phone */
  .proto-form-row {
    grid-template-columns: 1fr;
  }

  /* Form inputs: taller for touch comfort */
  .proto-form-input,
  .proto-form-select {
    min-height: 44px;
    padding: 10px 14px;
    font-size: 1rem; /* prevent iOS zoom */
  }

  .proto-form-textarea {
    font-size: 1rem;
  }

  /* Modal footer buttons: full width stack */
  .proto-modal-footer {
    flex-direction: column-reverse;
    gap: 8px;
  }

  .proto-modal-footer .proto-btn {
    width: 100%;
    justify-content: center;
    min-height: 48px;
    font-size: 0.95rem;
  }

  /* Close button: bigger tap target */
  .proto-modal-close {
    width: 36px;
    height: 36px;
    min-width: 36px;
  }

  /* --- Calendar --- */
  /* Hide the horizontal hour-timeline; leave only rows */
  .proto-cal-header-row {
    display: none;
  }

  .proto-cal-person-col {
    width: 80px;
  }

  /* --- AI prompt chips: ensure tap targets --- */
  .proto-ai-prompt-chip {
    min-height: 44px;
    padding: 10px;
    align-items: center;
  }

  /* AI panel: full width, not sticky */
  .proto-ai-panel {
    max-height: none;
  }

  /* AI input: prevent iOS zoom */
  .proto-ai-input {
    font-size: 1rem;
  }

  /* --- Footer --- */
  .proto-footer {
    padding: 16px;
  }

  .proto-footer-inner {
    flex-direction: column;
    gap: 8px;
    text-align: center;
    font-size: 0.78rem;
  }

  /* --- Toast: full width on phone --- */
  .proto-toast {
    bottom: 12px;
    right: 12px;
    left: 12px;
    max-width: unset;
  }

  /* --- Section header: allow wrapping --- */
  .proto-section-header {
    flex-wrap: wrap;
    gap: 8px;
  }

  .proto-section-meta {
    width: 100%;
    font-size: 0.78rem;
  }
}

/* ========================
   VERY SMALL PHONE — ≤430px
   Trim further without losing readability
   ======================== */

@media (max-width: 430px) {
  .proto-integrations-title {
    font-size: 1.05rem;
  }

  /* Role pill: icon only if screen is very tight */
  .proto-role-pill {
    padding: 0 10px;
    gap: 5px;
  }

  .proto-role-icon {
    font-size: 1.1rem;
  }

  /* Keep role label but shrink it */
  .proto-role-label {
    font-size: 0.72rem !important;
  }

  /* Vault card: reduce padding */
  .proto-vault-card {
    padding: 14px;
  }

  /* Section icon: smaller */
  .proto-section-icon {
    width: 26px;
    height: 26px;
  }
}

/* ========================
   REDUCED MOTION on mobile
   Smaller translate distances, faster durations
   ======================== */

@media (max-width: 767px) {
  /* Reduce fadeUp travel */
  @keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  /* Reduce stagger travel */
  @keyframes staggerFadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  /* Reduce timeline chip travel */
  @keyframes tl-chip-in {
    from { opacity: 0; transform: translateX(-6px); }
    to   { opacity: 1; transform: translateX(0); }
  }

  /* Reduce integration chip travel */
  @keyframes integ-chip-in {
    from { opacity: 0; transform: translateX(-8px); }
    to   { opacity: 1; transform: translateX(0); }
  }

  /* Faster durations — less jank on low-power phones */
  .proto-role-banner.active {
    animation-duration: 0.22s;
  }

  .proto-card-enter {
    animation-duration: 0.28s;
  }

  .proto-pw-step.active {
    animation-duration: 0.25s;
  }

  /* Suppress hover lift on touch devices */
  .proto-integ-card:hover {
    transform: none;
  }

  .proto-btn-primary:hover {
    transform: none;
  }

  .proto-role-pill:hover {
    transform: none;
  }
}

/* Respect OS-level prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ========================
   TOUCH INTERACTION — calendar event chips
   ======================== */

@media (hover: none) and (pointer: coarse) {
  /* Expand tap area on small calendar events */
  .proto-cal-event {
    min-width: 32px;
    /* No hover effects on touch */
    transition: none;
  }

  .proto-cal-event:hover {
    opacity: 0.92;
    transform: none;
    box-shadow: none;
  }

  /* Timeline chips: taller for touch */
  .proto-tl-chip {
    padding: 8px 9px;
    min-height: 36px;
  }

  /* Filter chips: taller */
  .proto-tl-filter {
    min-height: 44px;
    padding: 0 14px;
  }

  /* Walkthrough step dots: larger tap target */
  .proto-pw-step-dot {
    width: 20px;
    height: 20px;
    /* use padding to expand tap area */
    padding: 6px;
    margin: -6px;
    box-sizing: content-box;
  }

  /* Vault toggle: richer touch target (already handled in 767px block) */
  .proto-vault-toggle-switch {
    cursor: pointer;
  }

  /* AI suggestions and prompt chips */
  .proto-ai-suggestion-btn,
  .proto-ai-prompt-chip {
    min-height: 48px;
    align-items: center;
  }
}
