/* Public site styles (enhanced) */

:root {
    /* Core radii & motion */
    --gn-radius-sm: .35rem;
    --gn-radius: .75rem;
    --gn-radius-lg: 1.25rem;
    --gn-transition: .25s cubic-bezier(.4,0,.2,1);

    /* Brand Palette (Option 1 Modern & Trustworthy) */
    --gn-primary: #0D9488; /* Teal */
    --gn-primary-rgb: 13,148,136;
    --gn-primary-alt: #0F766E; /* darker teal for hover */
    --gn-secondary: #F0FDF4; /* Subtle soft green surface */
    --gn-accent: #FBBF24; /* Amber accent for premium / CTAs */
    --gn-accent-rgb: 251,191,36;
    --gn-text-primary: #1F2937; /* Gray 800 */
    --gn-text-secondary: #6B7280; /* Gray 500 */
    --gn-bg-light: #FFFFFF;
    --gn-bg-soft: #F9FAFB; /* Replaces previous soft background */
    --gn-bg-accent: #F0FDF4; /* Light tinted panel */

    /* Shadows */
    --gn-shadow-sm: 0 2px 4px rgba(0,0,0,.04); 
    --gn-shadow: 0 4px 18px -2px rgba(0,0,0,.08);
    --gn-shadow-lg: 0 12px 40px -8px rgba(0,0,0,.18);

    /* Gradients updated to reflect brand */
    --gn-gradient-hero: linear-gradient(135deg,#ffffff 0%,#F0FDF4 100%);
    --gn-gradient-cta: linear-gradient(135deg,#fff 0%,#F0FDF4 100%);
    --gn-gradient-accent: linear-gradient(120deg,#0D9488 0%,#0F766E 50%,#0D9488 100%);
    --gn-gradient-text: linear-gradient(90deg,#0D9488,#FBBF24);

    /* Glass & borders */
    --gn-bg-glass-light: rgba(255,255,255,.7);
    --gn-bg-glass-dark: rgba(31,41,55,.55);
    --gn-border-color: rgba(0,0,0,.08);
    --gn-border-color-dark: rgba(255,255,255,.12);

    /* Typography scale */
    --gn-font-sans: 'Inter', 'Sarabun', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --gn-h1: clamp(2.4rem, 5vw, 3.4rem);
    --gn-h2: clamp(1.9rem, 4vw, 2.6rem);
    --gn-h3: clamp(1.5rem, 2.6vw, 1.9rem);
    /* Article font stacks */
    --gn-font-serif-latin: 'Merriweather', Georgia, 'Times New Roman', Times, serif;
    --gn-font-serif-thai: 'Noto Serif Thai', 'Sarabun', Tahoma, 'Segoe UI', system-ui, sans-serif;
}

/* Global font */
body { font-family: var(--gn-font-sans); color: var(--gn-text-primary); font-size: 1rem; line-height: 1.55; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body .lead { font-size: 1.125rem; font-weight: 400; line-height: 1.55; }

/* Aspect Ratio Utilities (prevents CLS for dynamic media) */
.ratio-4x5 { aspect-ratio: 4 / 5; }
.ratio-3x4 { aspect-ratio: 3 / 4; }
.ratio-16x9 { aspect-ratio: 16 / 9; }
.ratio-square { aspect-ratio: 1 / 1; }

/* Section comfortable spacing */
section { padding-top: 4rem; padding-bottom: 4rem; }
@media (min-width: 992px){ section { padding-top: 5rem; padding-bottom: 5rem; } }

/* App store badges */
.app-store-badge img { display:block; height:auto; filter: drop-shadow(0 4px 12px rgba(0,0,0,.12)); transition: transform .2s ease, filter .2s ease; }
.app-store-badge:hover img { transform: translateY(-2px); filter: drop-shadow(0 8px 18px rgba(0,0,0,.18)); }

[data-bs-theme=dark] {
    --gn-gradient-hero: radial-gradient(circle at 20% 20%, #1f2630, #12161c);
    --gn-gradient-cta: linear-gradient(135deg,#1c2229,#242d38);
    --gn-bg-soft: #161b22;
    --gn-bg-accent: #203044;
    --gn-shadow-sm: 0 2px 4px rgba(0,0,0,.5); 
    --gn-shadow: 0 4px 18px -2px rgba(0,0,0,.55);
    --gn-shadow-lg: 0 12px 40px -8px rgba(0,0,0,.7);
    /* Improved contrast palette adjustments */
    --gn-text-secondary: #94a3b8; /* brighter than original gray for better contrast */
}

/* --- App Showcase Style --- */
.app-showcase { 
    display: flex;
    justify-content: center; 
    align-items: center; 
    padding: 1rem; 
}

.app-showcase img { 
    border-radius: 20px; /* Rounded corners to mimic device */
    border: 8px solid #343a40; /* Dark frame */
    box-shadow: 0 15px 30px rgba(0,0,0,0.15); /* Depth shadow */
    max-width: 350px; 
    height: auto; 
    background: #000; 
}

.hero-section { 
    background: var(--gn-gradient-hero); 
    position: relative;
    overflow: hidden;
}
.hero-section:before {
    content:"";
    position:absolute;inset:0;
    background: radial-gradient(circle at 80% 30%, rgba(56,123,255,.15), transparent 60%);
    pointer-events:none;
}
.hero-section .animated-bg {
    position:absolute;inset:0;overflow:hidden;z-index:0;pointer-events:none;
}
.hero-section .animated-bg span {
    position:absolute;
    display:block;
    width:420px;
    height:420px;
    border-radius:50%;
    filter:blur(70px);
    opacity:.35;
    animation: floatBlob 14s ease-in-out infinite;
    background: radial-gradient(circle at 30% 30%, rgba(var(--gn-primary-rgb),.55), transparent 70%);
    will-change: transform;
}
.hero-section .animated-bg span:nth-child(2){ top:10%; left:55%; animation-delay: -4s; background: radial-gradient(circle at 70% 40%, rgba(147,51,234,.55), transparent 70%); }
.hero-section .animated-bg span:nth-child(3){ top:55%; left:25%; animation-delay: -8s; background: radial-gradient(circle at 40% 60%, rgba(79,70,229,.55), transparent 70%); }
@keyframes floatBlob { 0%,100%{ transform:translateY(-30px) scale(1);} 50%{ transform:translateY(30px) scale(1.08);} }

.hero-section h1 { 
    line-height: 1.2; 
}

/* Hero title sizing (responsive) */
.hero-title { font-size: var(--gn-h1); line-height: 1.1; }

.final-cta { 
    background: var(--gn-gradient-cta); 
}

.navbar-brand { 
    font-size: 1.5rem; 
}

.brand-logo { width: 28px; height: 28px; display:inline-block; }

@media (max-width: 991.98px) {
    .hero-section { text-align: center; }
}

/* Cards */
.card {
    border: 1px solid var(--gn-border-color);
    border-radius: var(--gn-radius);
    transition: var(--gn-transition);
    -webkit-backdrop-filter: saturate(180%) blur(8px);
    backdrop-filter: saturate(180%) blur(8px);
}
.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--gn-shadow-lg);
}
[data-bs-theme=dark] .card { border-color: rgba(255,255,255,.08); }

/* Glass utility */
[data-bs-theme=dark] .card { border-color: rgba(255,255,255,.08); }

.glass { background: var(--gn-bg-glass-light); -webkit-backdrop-filter: blur(18px) saturate(180%); backdrop-filter: blur(18px) saturate(180%); border:1px solid rgba(255,255,255,.4); }
[data-bs-theme=dark] .glass { background: var(--gn-bg-glass-dark); border-color: rgba(255,255,255,.2); }

/* Gradient text */
.gradient-text { background: var(--gn-gradient-text); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* Button refinement */
.btn-gradient { background: var(--gn-gradient-accent); color:#fff; border:none; position:relative; overflow:hidden; }
.btn-gradient:focus-visible { outline:3px solid #9333ea; outline-offset:2px; }
.btn-gradient:hover { filter:brightness(1.05); }

/* Accent button (Amber) */
.btn-accent {
    --_bg: var(--gn-accent);
    --_bg-hover: color-mix(in srgb, var(--gn-accent) 88%, #000 12%);
    background: var(--_bg);
    color: #111827;
    border-color: var(--_bg);
}
.btn-accent:hover { background: var(--_bg-hover); border-color: var(--_bg-hover); color:#111827; }
.btn-accent:focus-visible { outline: 3px solid rgba(var(--gn-accent-rgb), .55); outline-offset: 2px; }

/* Skeleton loader */
.skeleton { position:relative; background:linear-gradient(90deg,#e5e7eb 0%,#f3f4f6 40%,#e5e7eb 80%); background-size:200% 100%; animation: skeleton 1.2s linear infinite; }
@keyframes skeleton { 0%{ background-position:200% 0;} 100%{ background-position:-200% 0;} }
[data-bs-theme=dark] .skeleton { background:linear-gradient(90deg,#2a3037 0%,#3a4250 40%,#2a3037 80%); }

img[data-fade] { opacity:0; transition:opacity .6s ease; }
img[data-fade].loaded { opacity:1; }

/* Blog cards image fit */
.card-img-top { object-fit: cover; height: 180px; }

/* Article body */
.article-page .article-body { font-size: 1.08rem; line-height: 1.85; }
.article-page .article-body p { margin-bottom: 1.1rem; }
.article-body img { max-width:100%; height:auto; border-radius: var(--gn-radius); box-shadow: var(--gn-shadow); margin:1.25rem 0; }
/* Article hero (responsive, constrained) */
.article-hero { background: #0f1419; }
.article-hero img.hero-img { object-fit: cover; }
@media (min-width: 992px){
    .article-hero { max-height: 480px; }
    .article-hero img.hero-img { height: 100%; }
}
@media (prefers-reduced-motion: no-preference){
    .article-hero img.hero-img { transition: transform .9s ease, filter .6s ease; }
    .article-hero:hover img.hero-img { transform: scale(1.03); }
}
/* Headings rhythm inside article */
.article-page .article-body h2 { margin-top: 2rem; margin-bottom: 1rem; }
.article-page .article-body h3 { margin-top: 1.5rem; margin-bottom: .75rem; }
.article-page .article-body blockquote { border-left: 3px solid var(--gn-primary); padding-left: 1rem; color: var(--gn-text-secondary); font-style: italic; }
.article-page .article-body a { color: var(--gn-primary); text-decoration: underline; text-underline-offset: 3px; }
.article-page .article-body a:hover { color: var(--gn-primary-alt); }
.article-page .article-body figure figcaption { font-size: .9rem; color: var(--gn-text-secondary); }

/* Apply serif font for readable articles (Thai-aware) */
.article-page .article-body, .article-page .article-body p, .article-page .article-body li {
    font-family: var(--gn-font-serif-thai), var(--gn-font-serif-latin);
}

/* Utility buttons */
#themeToggle { transition: var(--gn-transition); }
#themeToggle:hover { transform: translateY(-2px); }

/* Reading progress bar */
#readingProgressWrapper { position: fixed; top:0; left:0; width:100%; height:4px; z-index:1030; }
#readingProgress { height:100%; width:0; background: linear-gradient(90deg,#2563eb,#38bdf8); transition: width .15s linear; }
[data-bs-theme=dark] #readingProgress { background: linear-gradient(90deg,#60a5fa,#38bdf8); }

/* Search bar styling */
.blog-search-wrapper { position: sticky; top: 70px; z-index: 10; }
.blog-search { border-radius: var(--gn-radius-lg); box-shadow: var(--gn-shadow-sm); }
[data-bs-theme=dark] .blog-search { background:#0f1419; }

/* Fade in */
.fade-in { opacity:0; transform: translateY(10px); animation: fadeIn .6s forwards; }
@keyframes fadeIn { to { opacity:1; transform: none; } }

/* Nav adjustment for dark */
[data-bs-theme=dark] .navbar { border-color: rgba(255,255,255,.08)!important; }

/* Landing specific pricing refinement */
#pricing .card { transition: var(--gn-transition); }
#pricing .card:hover { box-shadow: var(--gn-shadow-lg); }
#pricing .badge { font-size: .7rem; letter-spacing: .5px; }

/* Blog card variations on landing */
.blog-card { border: none; background: var(--gn-bg-soft); box-shadow: var(--gn-shadow-sm); }
.blog-card:hover { transform: translateY(-6px); box-shadow: var(--gn-shadow); }
[data-bs-theme=dark] .blog-card { background:#141b23; }
.blog-card img { object-fit: cover; }

/* Utility object-fit helper (Bootstrap 5.3 provides .object-fit-cover upcoming; include fallback) */
.object-fit-cover { object-fit: cover; }

/* Accessible focus styles (high-contrast, unified) */
:root { --gn-focus-ring: #2563eb; --gn-focus-ring-dark: #60a5fa; }
:focus-visible {
    outline: 3px solid var(--gn-focus-ring);
    outline-offset: 3px;
}
[data-bs-theme=dark] :focus-visible { outline-color: var(--gn-focus-ring-dark); }
/* Provide additional focus treatment for elements that do not show outline well */
button:focus-visible, a:focus-visible, [role=button]:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--gn-focus-ring) 40%, transparent);
}
[data-bs-theme=dark] button:focus-visible,
[data-bs-theme=dark] a:focus-visible,
[data-bs-theme=dark] [role=button]:focus-visible,
[data-bs-theme=dark] input:focus-visible,
[data-bs-theme=dark] select:focus-visible,
[data-bs-theme=dark] textarea:focus-visible {
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--gn-focus-ring-dark) 35%, transparent);
}

/* Reduced motion preference: keep essential visibility transitions but remove decorative motion */
@media (prefers-reduced-motion: reduce) {
    html:focus-within { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
    /* Prevent layout jump for fade/slide elements; directly set final state */
    .fade-in, .reveal { opacity: 1 !important; transform: none !important; }
}

/* Reveal on scroll */
.reveal { opacity:0; transform: translateY(18px); transition: opacity .6s ease, transform .6s ease; }
.reveal-visible { opacity:1; transform:none; }

/* Typography scale application */
h1, .h1, h2, .h2, h3, .h3 { font-family: var(--gn-font-sans); font-weight: 600; letter-spacing: -.02em; }
h1, .h1 { font-size: var(--gn-h1); line-height: 1.15; }
h2, .h2 { font-size: var(--gn-h2); line-height: 1.2; }
h3, .h3 { font-size: var(--gn-h3); line-height: 1.25; }

/* Elevated pricing highlight */
.pricing-highlight { position:relative; }
.pricing-highlight:before { content:""; position:absolute; inset:-2px; border-radius:inherit; padding:2px; background:linear-gradient(120deg,var(--gn-primary), var(--gn-accent)); -webkit-mask:linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); mask:linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; }

/* Blog card hover effect */
.blog-card .ratio { position: relative; }
.blog-card .ratio::after { content:""; position:absolute; inset:0; background:linear-gradient(180deg, rgba(0,0,0,0) 60%, rgba(0,0,0,.25)); opacity:0; transition: opacity var(--gn-transition); }
.blog-card .ratio img { transition: transform .8s cubic-bezier(.25,.6,.3,1); }
.blog-card:hover .ratio img { transform: scale(1.06); }
.blog-card:hover .ratio::after { opacity:1; }

/* Fragment active nav highlight */
.nav-link.active-fragment { color: var(--gn-primary); }
.nav-link.active-fragment::after { content:""; position:absolute; left:0.75rem; right:0.75rem; bottom:0.35rem; height:2px; border-radius:2px; background: var(--gn-primary); opacity:.9; }
@media (prefers-reduced-motion:no-preference){
    .nav-link.active-fragment::after { transition:width .4s var(--gn-transition); }
}

/* Skip link utility (Bootstrap has visually-hidden but not focusable reveal) */
.visually-hidden-focusable:not(:focus):not(:active) { position:absolute !important; width:1px !important; height:1px !important; padding:0 !important; margin:-1px !important; overflow:hidden !important; clip:rect(0,0,0,0) !important; white-space:nowrap !important; border:0 !important; }

/* Footer styling */
.site-footer { background: var(--gn-bg-soft); border-top: 1px solid var(--gn-border-color); }
[data-bs-theme=dark] .site-footer { background: #0f172a; border-top-color: rgba(255,255,255,.08); }
.site-footer a { color: inherit; text-decoration: none; }
.site-footer a:hover { color: var(--gn-primary); text-decoration: underline; text-underline-offset: 2px; }

/* Dark mode gradient + text refinements */
[data-bs-theme=dark] .hero-section { background: linear-gradient(135deg, #0b1220 0%, #0f1b2e 100%); }
[data-bs-theme=dark] .hero-section .animated-bg span { opacity:.4; }
[data-bs-theme=dark] .gradient-text { background: linear-gradient(90deg, #34d399, #fbbf24); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* Global link styling */
a { text-decoration: none; transition: color .2s ease, text-decoration-color .2s ease; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
a:active { opacity:.9; }
[data-bs-theme=dark] a { color:#93c5fd; }
[data-bs-theme=dark] a:hover { color:#bfdbfe; }

/* Fix for heading colors in dark mode */
[data-bs-theme=dark] h1,
[data-bs-theme=dark] .h1,
[data-bs-theme=dark] h2,
[data-bs-theme=dark] .h2,
[data-bs-theme=dark] h3,
[data-bs-theme=dark] .h3 {
    color: var(--bs-light);
}

/* Improve text contrast in dark mode for muted & lead text */
[data-bs-theme=dark] .lead,
[data-bs-theme=dark] .text-muted {
    color: var(--bs-body-color) !important; /* Use the main readable body color */
    opacity: 0.85; /* Slight softening without losing accessibility */
}

/* Fix low-contrast text in features section for dark mode */
[data-bs-theme=dark] #features .list-unstyled li {
    color: var(--bs-body-color);
    opacity: 0.9;
}

/* Make primary color text brighter in dark mode */
[data-bs-theme=dark] .text-primary {
    color: #34d399 !important; /* lighter teal for dark backgrounds */
}

/* === FIX FOR TEXT CONTRAST ISSUES (Light + Dark) === */
/* Light mode: ensure muted & lead text use design token with good contrast */
body .lead,
body .text-muted {
    color: var(--gn-text-secondary);
}

/* Outline buttons contrast improvement */
[data-bs-theme=dark] .btn-outline-primary { color:#60a5fa; border-color:#3b82f6; }
[data-bs-theme=dark] .btn-outline-primary:hover { background:#1e3a8a; border-color:#2563eb; color:#fff; }
[data-bs-theme=dark] .btn-outline-secondary { color:#e2e8f0; border-color:#475569; }
[data-bs-theme=dark] .btn-outline-secondary:hover { background:#334155; border-color:#64748b; color:#fff; }
/* Dark mode feature list already brightened above; keep .text-primary override */

/* Pricing section dark mode refinement */
[data-bs-theme=dark] #pricing h2 { color: var(--bs-light); }

/* Replace earlier darker .text-muted in dark mode with a softer dedicated tone */
[data-bs-theme=dark] .text-muted {
    color: #cbd5e1 !important; /* Soft slate (improves contrast but less harsh than pure white) */
    opacity: 1; /* Ensure predictable rendering */
}

/* Preserve original (light-mode) color styling for pricing heading & subtitle across themes */
[data-bs-theme=dark] #pricing h2 {
    color: var(--gn-text-primary) !important; /* Keep same tone as light mode */
}
[data-bs-theme=dark] #pricing .text-muted {
    color: var(--gn-text-secondary) !important; /* Revert to original muted tone inside pricing */
    opacity: 1 !important;
}

/* Fix for low-contrast article body text in dark mode */
[data-bs-theme=dark] .article-body {
    color: #e2e8f0; /* Light slate for improved readability against dark bg */
}

