/* ============================================================
   REGISTAR — subscription-ui.css
   ============================================================
   Visual styles for Phase C subscription lifecycle UI.
   Loads AFTER style.css so its body-class overrides win on cascade.

   Sections:
     1. Grace banner       (top strip, status === 'grace')
     2. Locked screen      (full-screen overlay, status === 'expired')
     3. Layout shifts      (when banner is present, push app down)
     4. Reduced motion     (respect prefers-reduced-motion)

   Severity colour notes:
     The grace banner is the only place in the app where colours
     deviate from the strict monochrome + lime palette. Three
     severity tiers map to existing CSS variables where possible:
       low      → --amber   (calm warning, ≥5 days remaining)
       high     → orange    (escalating, 2-4 days remaining)
       critical → --red     (final notice, ≤1 day remaining)
     This is deliberate: payment-failure warnings need to feel
     different from regular UI, or users tune them out and end
     up locked out.
   ============================================================ */


/* ============================================================
   1. GRACE BANNER
   ============================================================ */

   :root {
    --grace-banner-h: 44px;
    --orange:        #ff7a00;
    --orange-dim:    rgba(255, 122, 0, 0.12);
  }
  
  .grace-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--grace-banner-h);
    z-index: 110;       /* above app-header (z-index: 100) */
    display: flex;
    align-items: center;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--bg);
    border-bottom: 1px solid rgba(8, 8, 8, 0.2);
    animation: grace-slide-down var(--t-mid) var(--ease) both;
  }
  
  @keyframes grace-slide-down {
    from { transform: translateY(-100%); }
    to   { transform: translateY(0);     }
  }
  
  .grace-banner-inner {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
  }
  
  .grace-banner-icon {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(8, 8, 8, 0.18);
    border: 1px solid rgba(8, 8, 8, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
    color: var(--bg);
  }
  
  .grace-banner-text {
    flex: 1;
    min-width: 0;
    letter-spacing: 0.04em;
    /* truncate gracefully on narrow screens */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  .grace-banner-title {
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-right: 4px;
  }
  
  .grace-banner-message {
    /* inherits everything from .grace-banner-text */
  }
  
  .grace-banner-days {
    font-weight: 500;
    margin-left: 8px;
    padding: 2px 8px;
    background: rgba(8, 8, 8, 0.18);
    border-radius: var(--radius-sm);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }
  
  .grace-banner-cta {
    flex-shrink: 0;
    background: var(--bg);
    color: var(--text-primary);
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    text-decoration: none;
    transition: background var(--t-fast) var(--ease),
                transform var(--t-fast) var(--ease);
  }
  
  .grace-banner-cta:hover {
    background: #1a1a1a;
    text-decoration: none;
  }
  
  .grace-banner-cta:active {
    transform: scale(0.97);
  }
  
  /* ── Severity tiers ─────────────────────────────────────────── */
  
  .grace-banner-low {
    background: var(--amber);
  }
  
  .grace-banner-high {
    background: var(--orange);
  }
  
  .grace-banner-critical {
    background: var(--red);
    color: #ffffff;
  }
  
  .grace-banner-critical .grace-banner-icon {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.4);
    color: #ffffff;
  }
  
  .grace-banner-critical .grace-banner-days {
    background: rgba(255, 255, 255, 0.18);
  }
  
  .grace-banner-critical .grace-banner-cta {
    background: #ffffff;
    color: var(--red);
  }
  
  .grace-banner-critical .grace-banner-cta:hover {
    background: #f5f5f5;
  }
  
  /* Subtle pulse on critical tier — draws the eye without being annoying */
  .grace-banner-critical .grace-banner-icon {
    animation: grace-pulse 1.6s ease-in-out infinite;
  }
  
  @keyframes grace-pulse {
    0%, 100% { transform: scale(1); }
    50%       { transform: scale(1.1); }
  }
  
  
  /* ============================================================
     2. LAYOUT SHIFTS WHEN BANNER PRESENT
     ============================================================
     Push app-header, sidebar, and app-layout down so they don't
     sit underneath the banner. Higher specificity (body.has-...)
     wins on cascade without needing !important.
     ============================================================ */
  
  body.has-grace-banner .app-header {
    top: var(--grace-banner-h);
  }
  
  body.has-grace-banner .sidebar {
    top: calc(var(--header-h) + var(--grace-banner-h));
  }
  
  body.has-grace-banner .app-layout {
    margin-top: calc(var(--header-h) + var(--grace-banner-h));
    height: calc(100vh - var(--header-h) - var(--grace-banner-h));
  }
  
  /* Login gate already has z-index 9000 — banner z-index 110 sits below it,
     so the banner doesn't poke through the login screen. No override needed. */
  
  
  /* ============================================================
     3. LOCKED SCREEN
     ============================================================
     Full-screen overlay shown when status === 'expired'.
     Sits above everything except the login gate (which it's
     mutually exclusive with — locked screen only renders post-login).
     ============================================================ */
  
  .locked-screen {
    position: fixed;
    inset: 0;
    z-index: 8000;       /* above grace banner (110) and app-header (100); below login gate (9000) */
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
    overflow-y: auto;
    animation: locked-fade-in var(--t-slow) var(--ease) both;
  }
  
  @keyframes locked-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
  }
  
  /* Lock body scroll while overlay is shown so the user can't scroll
     the underlying app sideways through the gap. */
  body.has-locked-screen {
    overflow: hidden;
  }
  
  .locked-screen-content {
    width: 100%;
    max-width: 640px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    animation: locked-rise var(--t-slow) var(--ease) both;
    animation-delay: 80ms;
  }
  
  @keyframes locked-rise {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0);    }
  }
  
  .locked-screen-brand {
    font-family: var(--font-heading);
    font-size: 36px;
    letter-spacing: 0.1em;
    color: var(--accent);
    line-height: 1;
    margin-bottom: 6px;
  }
  
  .locked-screen-title {
    font-family: var(--font-heading);
    font-size: 32px;
    letter-spacing: 0.06em;
    line-height: 1.1;
    color: var(--text-primary);
    margin: 24px 0 12px;
    font-weight: 400;
  }
  
  .locked-screen-message {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary);
    max-width: 460px;
    margin: 0 0 36px;
  }
  
  /* ── Resubscribe option cards ───────────────────────────────── */
  
  .locked-screen-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    width: 100%;
    margin-bottom: 32px;
  }
  
  .locked-screen-option {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px 20px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: border-color var(--t-fast) var(--ease),
                background var(--t-fast) var(--ease),
                box-shadow var(--t-fast) var(--ease),
                transform var(--t-fast) var(--ease);
  }
  
  /* Both cards light up identically when hovered — lime border,
     a subtle tinted fill, a soft glow and a slight lift. At rest
     neither card is lit, so the two sides behave symmetrically. */
  .locked-screen-option:hover {
    border-color: var(--accent);
    background: var(--accent-dim);
    box-shadow: 0 0 24px var(--accent-glow);
    transform: translateY(-2px);
  }
  
  .locked-screen-option-tier {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 12px;
  }
  
  .locked-screen-option-pro .locked-screen-option-tier {
    color: var(--accent);
  }
  
  .locked-screen-option-price {
    display: flex;
    align-items: baseline;
    gap: 4px;
    margin-bottom: 12px;
  }
  
  .locked-screen-price-amount {
    font-family: var(--font-heading);
    font-size: 40px;
    letter-spacing: 0.04em;
    line-height: 1;
    color: var(--text-primary);
  }
  
  .locked-screen-option-pro .locked-screen-price-amount {
    color: var(--accent);
  }
  
  .locked-screen-price-period {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 0.08em;
  }
  
  .locked-screen-option-desc {
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-secondary);
    margin-bottom: 20px;
    min-height: 56px;
  }
  
  .locked-screen-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    background: var(--surface-raised);
    color: var(--text-primary);
    border: 1px solid var(--border-hover);
    padding: 11px 18px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    text-decoration: none;
    transition: background var(--t-fast) var(--ease),
                border-color var(--t-fast) var(--ease),
                transform var(--t-fast) var(--ease),
                box-shadow var(--t-fast) var(--ease);
  }
  
  /* Both resubscribe buttons sit dark at rest and light up solid
     lime on hover, then return to dark when the pointer leaves —
     symmetric with the option cards above. */
  .locked-screen-cta:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--text-on-accent);
    box-shadow: 0 0 20px var(--accent-glow);
    text-decoration: none;
  }
  
  .locked-screen-cta:active {
    transform: scale(0.98);
  }
  
  /* ── Footer (sign out, support) ─────────────────────────────── */
  
  .locked-screen-footer {
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 0.08em;
  }
  
  .locked-screen-signout,
  .locked-screen-support {
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
    font-size: inherit;
    letter-spacing: inherit;
    color: var(--text-secondary);
    cursor: pointer;
    text-decoration: none;
    transition: color var(--t-fast) var(--ease);
  }
  
  .locked-screen-signout:hover,
  .locked-screen-support:hover {
    color: var(--accent);
    text-decoration: none;
  }
  
  .locked-screen-divider {
    color: var(--text-muted);
    user-select: none;
  }
  
  
  /* ============================================================
     4. NARROW VIEWPORTS
     ============================================================
     Below ~520px the grace banner can run out of horizontal room
     for icon + text + days badge + CTA. We hide the days badge
     first (the colour and pulse already convey urgency), then
     shrink the CTA padding if needed.
     ============================================================ */
  
  @media (max-width: 520px) {
    .grace-banner-days {
      display: none;
    }
    .grace-banner-inner {
      gap: 8px;
      padding: 0 12px;
    }
    .grace-banner-cta {
      padding: 6px 10px;
      font-size: 10px;
    }
    .locked-screen-title {
      font-size: 26px;
    }
    .locked-screen-options {
      grid-template-columns: 1fr;
    }
  }
  
  
  /* ============================================================
     5. REDUCED MOTION
     ============================================================
     Honour the user's OS-level preference for reduced animation.
     ============================================================ */
  
  @media (prefers-reduced-motion: reduce) {
    .grace-banner,
    .locked-screen,
    .locked-screen-content,
    .grace-banner-critical .grace-banner-icon {
      animation: none !important;
    }
  }