/* ============================================================
   polish.css  —  the smooth-and-buttery layer
   Loaded last on every page. Tightens micro-interactions across
   landing / dashboard / admin / invite so the whole product
   feels like one coherent thing.

   This file does NOT override layout or color tokens — it only
   adds motion, focus, hover lift, tap feedback, and unified
   form/button behaviour.

   Sections:
     1. Motion tokens
     2. Universal focus + tap
     3. Buttons — both .btn--primary (landing) and .btn-primary
        (dashboard/admin) families
     4. Form inputs (text/email/select/textarea)
     5. Cards + tile lift
     6. Pills, chips, tags
     7. Links
     8. Page entry animation
     9. Scrollbar
    10. Mobile refinements
   ============================================================ */


/* ============================================================
   1. MOTION TOKENS  —  one easing system, everywhere
   ============================================================ */
:root {
  --motion-fast:    140ms;
  --motion-base:    220ms;
  --motion-slow:    420ms;

  --ease-out-smooth: cubic-bezier(0.22, 1, 0.36, 1);   /* buttery default */
  --ease-out-snap:   cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring:     cubic-bezier(0.34, 1.56, 0.64, 1);

  --focus-ring:        0 0 0 3px color-mix(in oklch, var(--color-primary, #2c6fb8) 32%, transparent);
  --focus-ring-strong: 0 0 0 4px color-mix(in oklch, var(--color-primary, #2c6fb8) 45%, transparent);

  --lift-shadow-sm: 0 2px 6px rgba(20, 30, 60, 0.06), 0 8px 22px -8px rgba(20, 30, 60, 0.14);
  --lift-shadow-md: 0 4px 12px rgba(20, 30, 60, 0.07), 0 18px 40px -16px rgba(20, 30, 60, 0.20);
  --lift-shadow-lg: 0 6px 18px rgba(20, 30, 60, 0.09), 0 30px 60px -24px rgba(20, 30, 60, 0.28);
}


/* ============================================================
   2. UNIVERSAL FOCUS + TAP HIGHLIGHT
   ============================================================ */
* { -webkit-tap-highlight-color: transparent; }

a, button, [role="button"], [role="link"], input, textarea, select, summary {
  -webkit-tap-highlight-color: transparent;
}

/* Replace the harsh outline:2px solid with a soft, glowing ring */
:focus-visible {
  outline: none !important;
  box-shadow: var(--focus-ring);
  transition: box-shadow var(--motion-fast) var(--ease-out-smooth);
}

button:focus-visible,
a:focus-visible,
[role="button"]:focus-visible {
  outline: none !important;
  box-shadow: var(--focus-ring-strong);
}


/* ============================================================
   3. BUTTONS  —  unified feel across both naming conventions
   ============================================================ */

/* Landing-style (BEM): .btn--primary, .btn--ghost, .btn--large
   Dashboard-style:    .btn-primary, .btn-secondary, .btn-ghost
   Apply identical motion to both. */

.btn,
.btn--primary,
.btn--ghost,
.btn--large,
.btn-primary,
.btn-secondary,
.btn-ghost,
.btn-danger-ghost {
  position: relative;
  isolation: isolate;
  transition:
    transform var(--motion-base) var(--ease-out-smooth),
    box-shadow var(--motion-base) var(--ease-out-smooth),
    background-color var(--motion-base) var(--ease-out-smooth),
    color var(--motion-base) var(--ease-out-smooth),
    border-color var(--motion-base) var(--ease-out-smooth) !important;
  will-change: transform;
}

/* Hover lift — applies to every primary button family */
.btn--primary:not([disabled]):hover,
.btn-primary:not([disabled]):hover {
  transform: translateY(-1.5px);
  box-shadow: 0 12px 28px -10px color-mix(in oklch, var(--color-primary, #2c6fb8) 75%, transparent),
              0 2px 6px rgba(20, 30, 60, 0.08);
}

.btn--ghost:not([disabled]):hover,
.btn-secondary:not([disabled]):hover,
.btn-ghost:not([disabled]):hover {
  transform: translateY(-1px);
  box-shadow: var(--lift-shadow-sm);
}

/* Active state — tactile press */
.btn:not([disabled]):active,
.btn--primary:not([disabled]):active,
.btn--ghost:not([disabled]):active,
.btn--large:not([disabled]):active,
.btn-primary:not([disabled]):active,
.btn-secondary:not([disabled]):active,
.btn-ghost:not([disabled]):active,
.btn-danger-ghost:not([disabled]):active {
  transform: translateY(0) scale(0.985);
  transition-duration: var(--motion-fast);
}

/* Disabled */
.btn[disabled],
.btn--primary[disabled],
.btn-primary[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* Focus ring on primary buttons sits OUTSIDE the button shape */
.btn--primary:focus-visible,
.btn-primary:focus-visible {
  box-shadow:
    0 0 0 4px color-mix(in oklch, var(--color-primary, #2c6fb8) 30%, transparent),
    0 8px 22px -8px color-mix(in oklch, var(--color-primary, #2c6fb8) 70%, transparent);
}


/* ============================================================
   4. FORM INPUTS  —  smooth focus, real interactive feel
   ============================================================ */

input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
textarea,
select {
  transition:
    border-color var(--motion-base) var(--ease-out-smooth),
    box-shadow var(--motion-base) var(--ease-out-smooth),
    background-color var(--motion-base) var(--ease-out-smooth) !important;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):hover,
textarea:hover,
select:hover {
  border-color: color-mix(in oklch, var(--color-text, #1f2433) 35%, var(--color-border, #d9cdb1));
}

input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):focus,
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):focus-visible,
textarea:focus,
textarea:focus-visible,
select:focus,
select:focus-visible {
  outline: none !important;
  border-color: var(--color-primary, #2c6fb8) !important;
  box-shadow:
    0 0 0 4px color-mix(in oklch, var(--color-primary, #2c6fb8) 18%, transparent),
    0 1px 2px rgba(20, 30, 60, 0.04) !important;
}


/* ============================================================
   5. CARDS + TILE LIFT  —  subtle, optional
   ============================================================ */

/* Cards that are themselves links (template grid, etc.) lift on hover */
a.feature-card,
a.gallery__card,
a.cinema-prev,
a.tier {
  transition:
    transform var(--motion-base) var(--ease-out-smooth),
    box-shadow var(--motion-base) var(--ease-out-smooth);
}

a.feature-card:hover,
a.gallery__card:hover,
a.cinema-prev:hover,
a.tier:hover {
  transform: translateY(-3px);
  box-shadow: var(--lift-shadow-lg);
}


/* ============================================================
   6. PILLS, CHIPS, TAGS  —  smooth toggle feel
   ============================================================ */

.pill,
.chip,
.tag,
.tier-tag,
.swatch,
.palette-picker__chip,
.palette-picker__swatch,
.segmented__option,
[role="tab"] {
  transition:
    transform var(--motion-base) var(--ease-out-smooth),
    background-color var(--motion-base) var(--ease-out-smooth),
    border-color var(--motion-base) var(--ease-out-smooth),
    color var(--motion-base) var(--ease-out-smooth),
    box-shadow var(--motion-base) var(--ease-out-smooth);
}

.pill:hover,
.chip:hover,
.palette-picker__chip:hover,
.segmented__option:hover,
[role="tab"]:hover {
  transform: translateY(-1px);
}

.pill:active,
.chip:active,
.palette-picker__chip:active,
.segmented__option:active,
[role="tab"]:active {
  transform: translateY(0) scale(0.97);
}


/* ============================================================
   7. LINKS  —  unified hover behavior
   ============================================================ */

a:not(.btn):not(.btn--primary):not(.btn--ghost):not(.btn-primary):not(.btn-secondary):not(.btn-ghost):not(.tier):not(.feature-card):not(.gallery__card):not(.cinema-prev) {
  transition:
    color var(--motion-base) var(--ease-out-smooth),
    opacity var(--motion-base) var(--ease-out-smooth);
}


/* ============================================================
   8. PAGE ENTRY ANIMATION  —  gentle fade-up on first paint
   ============================================================ */

@keyframes polish-fade-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: no-preference) {
  /* Apply to page-level main containers — but never to elements that
     already have their own entrance animations (invite hero, etc.).
     NOTE: .dash-main intentionally excluded — its mobile preview pane uses
     position:fixed children, and an active `transform` on an ancestor
     creates a CSS containing block that traps fixed descendants. */
  body > main:not(.inv-shell):not(.invite-stage):not(.dash-main),
  body > .hero,
  body > .site {
    animation: polish-fade-up 520ms var(--ease-out-smooth) both;
  }
}


/* ============================================================
   9. SCROLLBAR  —  thin, themed (desktop only)
   ============================================================ */

@media (pointer: fine) {
  * {
    scrollbar-width: thin;
    scrollbar-color: var(--color-border, #d9cdb1) transparent;
  }
  *::-webkit-scrollbar { width: 10px; height: 10px; }
  *::-webkit-scrollbar-track { background: transparent; }
  *::-webkit-scrollbar-thumb {
    background: var(--color-border, #d9cdb1);
    border-radius: 9999px;
    border: 2px solid transparent;
    background-clip: padding-box;
  }
  *::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-muted, #6f6a5e);
    background-clip: padding-box;
    border: 2px solid transparent;
  }
}


/* ============================================================
   10. MOBILE REFINEMENTS  —  comfortable tap targets, no jitter
   ============================================================ */

@media (max-width: 720px) {
  /* Disable hover lifts on touch — translateY sticks on tap-and-hold */
  @media (hover: none) {
    .btn--primary:hover,
    .btn-primary:hover,
    .btn--ghost:hover,
    .btn-secondary:hover,
    .btn-ghost:hover,
    a.feature-card:hover,
    a.gallery__card:hover,
    a.cinema-prev:hover,
    a.tier:hover,
    .pill:hover,
    .chip:hover {
      transform: none;
    }
  }

  /* All primary CTAs at least 48px tall — Apple HIG */
  .btn--primary,
  .btn--large,
  .btn-primary {
    min-height: 48px;
    padding-block: 14px;
  }

  /* Inputs at least 48px tall, 16px font (prevents iOS zoom) */
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
  textarea,
  select {
    min-height: 48px;
    font-size: max(16px, 1rem);
  }
}


/* ============================================================
   11. REDUCED MOTION  —  honour the preference everywhere
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}


/* ============================================================
   11. DESIGNER CORRECTIONS  —  restraint over decoration
   Following the principle: earn every color, kill every link tell,
   one CTA per viewport, no faux-handwritten italic flourishes.
   ============================================================ */

/* --- Headline: kill the blue italic flourish ----------------- */
/* "Invitations that move people." now reads as one cohesive
   headline. Italic remains for subtle rhythm, but the color and
   weight match the rest so it no longer screams.               */
.hero .hero__copy h1 em,
.hero h1 em {
  color: var(--color-text) !important;
  font-style: italic;
  font-weight: 500;
}

/* --- Hero quiet-link: replaced with a real secondary button --- */
/* On the page itself we'll hide it; the templates section is the
   next scroll target, no link needed.                           */
.hero__cta .hero__quietlink,
.hero__quietlink {
  display: none !important;
}

/* --- Header on mobile: one CTA only --------------------------- */
/* The hero already has "See it move". The header doesn't need a
   second blue button competing with it.                         */
@media (max-width: 720px) {
  .header__actions .btn--primary,
  .header__actions .btn[href="/dashboard/"]:not(.nav__signin) {
    display: none;
  }
  /* Bring back the View preview as the single header CTA — small ghost */
  .header__actions a.btn--ghost {
    display: inline-flex;
    padding: 8px 14px;
    font-size: 0.85rem;
    border-radius: 999px;
  }
}

/* --- Hero CTA on mobile: button not full-bleed ---------------- */
/* Full-width neon-blue buttons are an app pattern, not a brand
   pattern. Cap the width so it reads as deliberate.             */
@media (max-width: 720px) {
  .hero__cta {
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
  }
  .hero__cta .btn--primary,
  .hero__cta .btn--large {
    width: auto;
    align-self: center;
    padding: 14px 28px;
    font-size: 0.95rem;
  }
}

/* --- Meta strip: soften ------------------------------------- */
/* Drop the harsh top divider and the all-caps tracking on the
   labels. Numbers stay editorial; rest steps back.              */
.hero__meta {
  border-top: none !important;
  padding-top: var(--space-4) !important;
  margin-top: var(--space-8) !important;
  gap: var(--space-8) !important;
  display: flex !important;
  flex-wrap: wrap;
}
.hero__meta li {
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.85rem;
  display: flex !important;
  flex-direction: column !important;
  gap: 2px !important;
  min-width: 0;
}
.hero__meta li span {
  font-style: normal !important;
  font-size: clamp(1.2rem, 2.2vw, 1.5rem) !important;
  color: var(--color-text) !important;
  font-weight: 600;
  display: block;
}

/* --- Mobile meta strip: tighter still ------------------------ */
@media (max-width: 720px) {
  .hero__meta {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-3) !important;
    margin-top: var(--space-6) !important;
    padding-top: var(--space-4) !important;
  }
  .hero__meta li {
    font-size: 0.72rem;
    text-align: left;
  }
  .hero__meta li span {
    font-size: 1.05rem !important;
  }
}

/* --- Header layout: never wrap "UR Invited" ------------------ */
.header__inner {
  flex-wrap: nowrap;
}
.logo {
  flex-shrink: 0;
  white-space: nowrap;
}
.logo span {
  white-space: nowrap;
}

/* --- Hero overline: subtler --------------------------------- */
.hero__overline {
  font-size: 11px !important;
  letter-spacing: 0.04em;
  opacity: 0.85;
}

/* --- Reduce blue in body links across the page --------------- */
/* Anywhere a default <a> exists inside content, make it inherit
   color and only get an underline-on-hover. Buttons are exempt. */
.hero__lead a:not(.btn),
.section a:not(.btn):not(.nav a):not(.tile a):not(.card a) {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid color-mix(in oklab, currentColor 30%, transparent);
  transition: border-color 180ms ease;
}
.hero__lead a:not(.btn):hover,
.section a:not(.btn):hover {
  border-bottom-color: currentColor;
}


/* ============================================================
   12. HERO TIER STRIP  —  two editions, visible above the fold
   Replaces the old meta strip. Two clickable cards side-by-side
   that anchor to #pricing. Cinematic is the featured one.
   ============================================================ */

.hero__tiers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  margin-top: var(--space-8);
  max-width: 520px;
}

.hero__tiers--single {
  grid-template-columns: 1fr;
  max-width: 460px;
}

.hero__tiers--single .hero__tier {
  padding: 18px 22px;
}

.hero__tiers--single .hero__tier-name {
  font-family: var(--font-display);
  text-transform: none;
  letter-spacing: 0;
  font-style: italic;
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--color-text);
  margin-top: 4px;
}

.hero__tiers--single .hero__tier-desc {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.hero__tier {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border-radius: 16px;
  background: color-mix(in oklab, var(--color-surface) 88%, transparent);
  border: 1px solid var(--color-border);
  text-decoration: none;
  color: var(--color-text);
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.hero__tier:hover {
  transform: translateY(-2px);
  border-color: color-mix(in oklab, var(--color-text) 30%, var(--color-border));
  box-shadow: 0 8px 24px -10px rgba(0,0,0,0.15);
}

.hero__tier-name {
  font-family: var(--font-body);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--color-text-muted);
}

.hero__tier-price {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--color-text);
  line-height: 1;
  margin-top: 2px;
}

.hero__tier-desc {
  font-family: var(--font-body);
  font-size: 0.78rem;
  color: var(--color-text-muted);
  line-height: 1.3;
  margin-top: 4px;
}

/* Featured (Cinematic): brand cream + clay accent so it visibly leads */
.hero__tier--featured {
  background: linear-gradient(135deg,
    color-mix(in oklab, var(--color-primary) 8%, var(--color-surface)) 0%,
    var(--color-surface) 100%);
  border-color: color-mix(in oklab, var(--color-primary) 35%, var(--color-border));
}
.hero__tier--featured .hero__tier-name { color: var(--color-primary); }
.hero__tier--featured .hero__tier-price { color: var(--color-primary); }

.hero__tier-badge {
  position: absolute;
  top: -9px;
  right: 12px;
  font-family: var(--font-body);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--color-primary);
  color: #fff;
  line-height: 1.4;
}

.hero__tiers-note {
  margin-top: var(--space-3);
  font-family: var(--font-body);
  font-size: 0.75rem;
  color: var(--color-text-muted);
  letter-spacing: 0.02em;
}

/* Mobile: stack but keep both visible at once */
@media (max-width: 720px) {
  .hero__tiers {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: var(--space-6);
    max-width: 100%;
  }
  .hero__tier {
    padding: 22px 12px 12px;
    border-radius: 14px;
  }
  .hero__tier-name { font-size: 0.62rem; }
  .hero__tier-price { font-size: 1.2rem; }
  .hero__tier-desc { font-size: 0.7rem; }
  .hero__tier-badge {
    top: 8px;
    right: 8px;
    font-size: 0.5rem;
    padding: 2px 6px;
  }
}

/* --- Hero phone: cinematic edition badge ----------------------- */
.hero-mini__edition {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 0.55rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(31, 36, 51, 0.08);
  color: var(--color-text);
  margin-bottom: 6px;
  align-self: center;
}


/* ============================================================
   13. PRICING ORDER  —  Cinematic leads on mobile
   On desktop the two-column grid puts Cinematic on the right
   (visually "after" Classic). On mobile we stack — put the
   flagship Cinematic FIRST so it gets the impression.
   ============================================================ */
@media (max-width: 720px) {
  .pricing__grid--two { display: flex; flex-direction: column; gap: var(--space-5); }
  .pricing__grid--two .tier { order: 2; }
  .pricing__grid--two .tier--featured,
  .pricing__grid--two .tier--cinema { order: 1; }
}


/* ============================================================
   14. INLINE TEXT GUARD — Character counter badge (Sprint 7.2)
   Shared across all 3 templates. The badge is injected
   immediately after each [contenteditable][data-field] element
   by shared/inline-text-guard.js.
   ============================================================ */
.uv-char-counter {
  position: absolute;
  font-size: 11px;
  color: rgba(0, 0, 0, 0.5);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}
/* Bug 3 (Sprint 12.4): visibility is governed solely by :focus so counters no
   longer bleed into the preview on first scroll. --near-limit keeps only its
   colour/weight emphasis — it no longer forces visibility when unfocused. */
[contenteditable="true"]:focus + .uv-char-counter { opacity: 1; }
.uv-char-counter--near-limit { color: #c25a3a; font-weight: 600; }
@media (prefers-reduced-motion: reduce) {
  .uv-char-counter { transition: none; }
}
