/* Hide Alpine.js x-cloak elements before Alpine initializes to prevent FOUC */
[x-cloak] { display: none !important; }

:root { /* Primary Colors - Brand Kit 2025 */
    --clover-purple: #3c78fd;    /* Primary blue */
    --law-navy: #1A2332;
    --paper-white: #F8F9FA;
    --leaf-green: #5B7D52;
    --petal-accent: #3c78fd;     /* accent — was purple #7200fc, now brand blue (name kept for compat) */
    --parchment: #F7F5F0;
    --neutral-gray: #58585a;     /* Brand gray */
    --gradient-cyan: #00ffff;    /* Gradient start */
    --gradient-purple: #3c78fd;  /* gradient end — was purple #7200fc, now brand blue (gradient is cyan→blue) */

    /* Bootstrap overrides */
    --bs-primary: var(--clover-purple);
    --bs-primary-rgb: 60, 120, 253;
    --bs-secondary: var(--leaf-green);
    --bs-secondary-rgb: 91, 125, 82;
    --bs-dark: var(--law-navy);
    --bs-dark-rgb: 26, 35, 50;
    --bs-light: var(--parchment);
    --bs-light-rgb: 247, 245, 240;

    /* === Structural tokens (design-system Section C, Phase 3) ===
       Structure follows the Claude Design system; values are consolidated
       from the hexes the app already shipped, so adopting a token is a
       refactor, not a redesign. Prefer these over raw hex in app CSS.
       Contract + remaining phases: docs/wiki/ref-design-system.md. */

    /* Neutral text ladder (on light surfaces) */
    --tri-fg-1: #374151;            /* primary body text */
    --tri-fg-2: #6b7280;            /* muted labels, quiet buttons */
    --tri-fg-3: #9ca3af;            /* faint microtext, counters */
    --tri-fg-on-dark: rgba(255, 255, 255, 0.8);

    /* Neutral borders & surfaces */
    --tri-border: #e5e7eb;          /* hairlines, subtle card borders */
    --tri-border-strong: #d1d5db;   /* inputs, outlined controls */
    --tri-bg-subtle: #f8f9fa;       /* quiet fills, hover rows */
    --tri-bg-hover: #f3f4f6;        /* ghost-button hover */

    /* Semantic ramps (600 = base; higher = darker text, lower = tints) */
    --tri-success-600: #198754;
    --tri-success-800: #0f5132;
    --tri-success-200: #c3e6cb;
    --tri-success-50: #f6fdf9;
    --tri-success-rgb: 25, 135, 84;
    --tri-info-600: #0284c7;
    --tri-info-700: #0369a1;
    --tri-info-100: #e0f2fe;
    --tri-info-200: #bae6fd;
    --tri-warning-600: #fd7e14;
    --tri-warning-700: #d97706;
    --tri-rating-star: #ffd700;

    /* Spacing scale (4px base) — prefer for new spacing */
    --tri-space-1: 0.25rem;
    --tri-space-2: 0.5rem;
    --tri-space-3: 0.75rem;
    --tri-space-4: 1rem;
    --tri-space-6: 1.5rem;
    --tri-space-8: 2rem;
    --tri-space-12: 3rem;
    --tri-space-16: 4rem;

    /* Radii */
    --tri-radius-xs: 0.25rem;
    --tri-radius-sm: 0.375rem;
    --tri-radius-md: 0.5rem;
    --tri-radius-lg: 0.75rem;
    --tri-radius-xl: 1.125rem;      /* chat bubbles */
    --tri-radius-pill: 50rem;

    /* Shadows / elevation */
    --tri-shadow-xs: 0 1px 3px rgba(0, 0, 0, 0.05);
    --tri-shadow-sm: 0 4px 8px rgba(0, 0, 0, 0.15);
    --tri-shadow-md: 0 4px 20px rgba(0, 0, 0, 0.08);
    --tri-shadow-lg: 0 6px 24px rgba(0, 0, 0, 0.12);
    --tri-shadow-focus: 0 0 0 3px rgba(var(--bs-primary-rgb), 0.1);
}

/* Font display optimization - prevent Flash of Invisible Text */
@font-face {
    font-family: 'bootstrap-icons';
    font-display: swap;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--paper-white);
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Playfair Display', Georgia, serif;
}

/* Fix Chrome v136+ H1UserAgentFontSizeInSection deprecation warning
 * Explicitly define h1 size regardless of sectioning element nesting
 * See: https://developer.mozilla.org/en-US/blog/h1-element-styles/
 * This ensures consistent h1 rendering as browsers phase out legacy nested sizing
 */
h1 {
    margin-block: 0.67em;
    font-size: 2em;
}

.logo {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 2.5rem;
    color: var(--clover-purple);
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
    line-height: 1;
    position: relative;
}

.logo-accent {
    color: var(--petal-accent);
    font-style: italic;
}

.navbar {
    background-color: var(--law-navy);
}

.navbar-dark .navbar-nav .nav-link {
    color: rgba(255, 255, 255, 0.8);
}

.navbar-dark .navbar-nav .nav-link:hover, .navbar-dark .navbar-nav .nav-link.active {
    color: white;
}

.navbar-dark .navbar-nav .nav-link.active::after {
    content: '';
    display: block;
    width: 100%;
    height: 2px;
    background-color: var(--petal-accent);
    margin-top: 2px;
}

.btn-primary {
    background-color: var(--clover-purple);
    border-color: var(--clover-purple);
}

.btn-primary:hover {
    background-color: #2b5fd9;
    border-color: #2b5fd9;
}

.form-control:focus {
    border-color: var(--clover-purple);
    box-shadow: 0 0 0 0.25rem rgba(60, 120, 253, 0.25);
}

.bg-gradient-primary {
    background: linear-gradient(90deg, var(--gradient-cyan) 0%, var(--gradient-purple) 100%);
}

.dropdown-menu {
    min-width: 0;
}

/* =========================
   MOBILE & STORE-APP POLISH
   (phone browsers + the TWA/WKWebView store shells)
   ========================= */

/* Navbar icon buttons (bell): a full-size touch target, always visible on
   phones — notifications must not hide behind the hamburger. */
.nav-icon-btn {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.nav-icon-btn .notification-badge {
    top: 6px;
    right: 4px;
    font-size: 0.6rem;
}

/* The notification panel may never exceed the phone viewport. */
.notification-dropdown {
    width: min(320px, calc(100vw - 1.5rem));
    max-height: min(400px, 70vh);
    overflow-y: auto;
}

/* Collapsed-navbar menu: comfortable, app-like tap targets. */
@media (max-width: 767.98px) {
    .navbar-nav .nav-link {
        padding-top: var(--tri-space-3);
        padding-bottom: var(--tri-space-3);
        font-size: 1.0625rem;
    }

    .navbar-collapse {
        padding-top: var(--tri-space-2);
        padding-bottom: var(--tri-space-2);
    }

    /* The user-menu trigger inside the collapse aligns with the nav links. */
    .navbar-collapse > .dropdown > .btn {
        padding-left: 0;
        padding-top: var(--tri-space-3);
        padding-bottom: var(--tri-space-3);
    }
}

/* Long prose clamped on phones by the data-clamp-mobile handler in
   ui-helpers.js, which appends the "Ver más" toggle that reveals the rest.
   The class is only ever applied by that handler, so no-JS renders in full. */
.is-clamped {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: var(--tri-clamp-lines, 3);
    line-clamp: var(--tri-clamp-lines, 3);
    overflow: hidden;
}

/* Touch behavior: no double-tap zoom delay on controls, no gray tap flash —
   Bootstrap's own :active states provide the feedback. */
.btn,
.nav-link,
.dropdown-item,
.form-control {
    touch-action: manipulation;
}

html {
    -webkit-tap-highlight-color: transparent;
}

/* Safe areas: with viewport-fit=cover the navbar and footer extend under the
   iOS notch / home indicator (and Android display cutouts) inside the store
   shells; pad them back into view. No-ops in regular browsers. */
@supports (padding: env(safe-area-inset-top)) {
    .navbar {
        padding-top: calc(0.5rem + env(safe-area-inset-top));
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

    .app-footer {
        padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    }
}

.app-footer {
    padding-bottom: 1rem;
}
