/* ============================================
   OpenAD Demo — Style
   Accessible, sobre, élégant
   ============================================ */

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #fafaf9;
    --bg-card: #ffffff;
    --bg-dark: #1c1917;
    --bg-accent: #f0f7f4;
    --text: #1c1917;
    --text-secondary: #57534e;
    --text-muted: #a8a29e;
    --primary: #166534;
    --primary-light: #dcfce7;
    --primary-dark: #14532d;
    --accent: #0369a1;
    --border: #e7e5e4;
    --border-focus: #166534;
    --error: #dc2626;
    --error-bg: #fef2f2;
    --success: #166534;
    --success-bg: #f0fdf4;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.12);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 20px;
    --font: 'DM Sans', -apple-system, sans-serif;
    --font-display: 'DM Serif Display', Georgia, serif;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible {
    outline: 3px solid var(--border-focus);
    outline-offset: 2px;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Skip link */
.skip-link {
    position: absolute;
    top: -100px;
    left: 16px;
    background: var(--primary);
    color: white;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    z-index: 1000;
    font-weight: 700;
}

.skip-link:focus {
    top: 16px;
}

/* Screen reader only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* ============================================
   Header
   ============================================ */
header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    font-size: 28px;
}

.logo-text {
    font-family: var(--font-display);
    font-size: 22px;
    line-height: 1.1;
    color: var(--primary-dark);
}

.logo-sub {
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

nav {
    display: flex;
    align-items: center;
    gap: 20px;
}

.nav-link {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

.nav-link:hover {
    color: var(--text);
    text-decoration: none;
}

.nav-btn {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    transition: background 0.2s;
}

.nav-btn:hover {
    background: var(--primary-dark);
    text-decoration: none;
    color: white;
}

/* ============================================
   Hero
   ============================================ */
.hero {
    background: linear-gradient(165deg, var(--bg-dark) 0%, #292524 100%);
    color: white;
    padding: 80px 20px;
}

.hero-inner {
    max-width: 800px;
    margin: 0 auto;
    text-align: center;
}

.hero-title {
    font-family: var(--font-display);
    font-size: clamp(28px, 5vw, 48px);
    line-height: 1.2;
    margin-bottom: 24px;
}

.hero-title em {
    color: #86efac;
    font-style: normal;
}

.hero-text {
    font-size: 17px;
    line-height: 1.7;
    color: #d6d3d1;
    max-width: 650px;
    margin: 0 auto 32px;
}

.hero-text strong {
    color: white;
    font-weight: 600;
}

.hero-actions {
    display: flex;
    gap: 14px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 12px 28px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
    text-align: center;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    text-decoration: none;
    color: white;
}

.btn-outline {
    background: transparent;
    color: white;
    border-color: rgba(255,255,255,0.3);
}

.btn-outline:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.5);
    text-decoration: none;
    color: white;
}

.btn-lg {
    padding: 16px 36px;
    font-size: 17px;
}

.btn-full {
    width: 100%;
}

/* Alerts */
.alert {
    max-width: 800px;
    margin: 20px auto;
    padding: 16px 20px;
    border-radius: var(--radius-sm);
    font-weight: 500;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid #bbf7d0;
}

.alert-error {
    background: var(--error-bg);
    color: var(--error);
    border: 1px solid #fecaca;
}

/* ============================================
   Toggle
   ============================================ */
.toggle-section {
    padding: 24px 20px;
    background: var(--bg-accent);
    border-bottom: 1px solid var(--border);
}

.toggle-inner {
    max-width: 800px;
    margin: 0 auto;
}

.toggle-box {
    text-align: center;
}

.toggle-button {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    background: none;
    border: none;
    cursor: pointer;
    font-family: var(--font);
    font-size: 15px;
    color: var(--text);
    padding: 10px 16px;
    border-radius: var(--radius);
    transition: background 0.2s;
}

.toggle-button:hover {
    background: rgba(0,0,0,0.04);
}

.toggle-track {
    display: inline-block;
    width: 52px;
    height: 28px;
    background: var(--primary);
    border-radius: 14px;
    position: relative;
    transition: background 0.3s;
    flex-shrink: 0;
}

.toggle-thumb {
    position: absolute;
    top: 3px;
    left: 27px;
    width: 22px;
    height: 22px;
    background: white;
    border-radius: 50%;
    transition: left 0.3s;
    box-shadow: var(--shadow-sm);
}

.toggle-button.off .toggle-track {
    background: #a8a29e;
}

.toggle-button.off .toggle-thumb {
    left: 3px;
}

.toggle-label {
    text-align: left;
}

.toggle-label strong {
    display: block;
    font-size: 14px;
}

.toggle-hint {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 8px;
}

/* ============================================
   Gallery
   ============================================ */
.gallery-section {
    padding: 60px 20px;
}

.gallery-inner {
    max-width: 1100px;
    margin: 0 auto;
}

.section-title {
    font-family: var(--font-display);
    font-size: 32px;
    text-align: center;
    margin-bottom: 8px;
}

.section-sub {
    text-align: center;
    color: var(--text-secondary);
    font-size: 15px;
    margin-bottom: 40px;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

.gallery-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    transition: box-shadow 0.3s, transform 0.2s;
}

.gallery-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card-image {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    background: #f5f5f4;
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255,255,255,0.92);
    padding: 4px 8px;
    border-radius: 20px;
    font-size: 16px;
    box-shadow: var(--shadow-sm);
}

.card-body {
    padding: 16px;
}

.card-type {
    display: inline-block;
    background: var(--primary-light);
    color: var(--primary-dark);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 8px;
}

.card-desc {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
}

.card-desc.no-desc {
    font-style: italic;
    opacity: 0.5;
}

.card-author {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 16px;
}

/* ============================================
   About
   ============================================ */
.about-section {
    padding: 60px 20px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
}

.about-inner {
    max-width: 1000px;
    margin: 0 auto;
}

.about-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 24px;
    margin-top: 40px;
}

.about-card {
    background: var(--bg);
    padding: 28px 24px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.about-icon {
    font-size: 32px;
    display: block;
    margin-bottom: 12px;
}

.about-card h3 {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 8px;
}

.about-card p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.about-compare {
    margin-top: 50px;
}

.about-compare h3 {
    font-family: var(--font-display);
    font-size: 24px;
    text-align: center;
    margin-bottom: 24px;
}

.compare-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.compare-col {
    padding: 28px 24px;
    border-radius: var(--radius);
}

.compare-col h4 {
    font-size: 18px;
    margin-bottom: 16px;
}

.compare-col p {
    font-size: 14px;
    line-height: 1.8;
    padding-left: 8px;
    border-left: 2px solid transparent;
    margin-bottom: 4px;
}

.compare-bad {
    background: #fef2f2;
    border: 1px solid #fecaca;
}

.compare-bad h4 { color: #991b1b; }
.compare-bad p { border-left-color: #fca5a5; color: #7f1d1d; }
.compare-bad em { font-style: italic; }

.compare-good {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
}

.compare-good h4 { color: #166534; }
.compare-good p { border-left-color: #86efac; color: #14532d; }

/* ============================================
   CTA
   ============================================ */
.cta-section {
    padding: 60px 20px;
    text-align: center;
    background: linear-gradient(165deg, var(--bg-dark) 0%, #292524 100%);
    color: white;
}

.cta-inner {
    max-width: 600px;
    margin: 0 auto;
}

.cta-inner h2 {
    font-family: var(--font-display);
    font-size: 28px;
    margin-bottom: 16px;
}

.cta-inner p {
    color: #d6d3d1;
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 28px;
}

/* ============================================
   Upload page
   ============================================ */
.upload-container {
    max-width: 640px;
    margin: 40px auto;
    padding: 0 20px;
}

.page-title {
    font-family: var(--font-display);
    font-size: 28px;
    text-align: center;
    margin-bottom: 8px;
}

.page-sub {
    text-align: center;
    color: var(--text-secondary);
    font-size: 15px;
    margin-bottom: 32px;
}

.upload-form {
    background: var(--bg-card);
    padding: 32px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
}

.form-group {
    margin-bottom: 24px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
}

.form-required {
    font-size: 11px;
    font-weight: 500;
    color: var(--primary);
    background: var(--primary-light);
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 6px;
}

input[type="text"],
select,
textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 15px;
    color: var(--text);
    background: white;
    transition: border-color 0.2s;
    -webkit-appearance: none;
}

input[type="text"]:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    outline: none;
}

textarea {
    resize: vertical;
    min-height: 100px;
}

select {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2357534e' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

.form-meta {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
}

.form-hint {
    font-size: 13px;
    color: var(--text-muted);
}

#charCounter {
    font-size: 12px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.guidance {
    background: var(--bg-accent);
    border-left: 3px solid var(--primary);
    padding: 12px 16px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 14px;
    color: var(--primary-dark);
    font-style: italic;
}

.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg);
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.upload-icon {
    font-size: 40px;
    display: block;
    margin-bottom: 12px;
}

.upload-zone p {
    font-size: 15px;
    color: var(--text-secondary);
}

.upload-hint {
    font-size: 13px !important;
    color: var(--text-muted) !important;
    margin-top: 4px;
}

#previewContainer {
    max-width: 100%;
}

#previewContainer img {
    max-height: 300px;
    margin: 0 auto;
    border-radius: var(--radius-sm);
}

/* ============================================
   Footer
   ============================================ */
footer {
    padding: 30px 20px;
    text-align: center;
    border-top: 1px solid var(--border);
}

.footer-inner p {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
    .hero { padding: 50px 20px; }
    .hero-text { font-size: 15px; }
    .gallery-grid { grid-template-columns: 1fr; gap: 16px; }
    .compare-grid { grid-template-columns: 1fr; }
    .about-grid { grid-template-columns: 1fr 1fr; }
    .upload-form { padding: 20px; }
    nav { gap: 12px; }
    .nav-link { display: none; }
}

@media (max-width: 480px) {
    .about-grid { grid-template-columns: 1fr; }
    .header-inner { padding: 10px 16px; }
    .logo-text { font-size: 18px; }
    .gallery-section, .about-section, .cta-section { padding: 40px 16px; }
}

/* ============================================
   Print
   ============================================ */
@media print {
    .toggle-section, .cta-section, nav, .skip-link { display: none; }
    .hero { background: none; color: black; padding: 20px; }
    .hero-title em { color: inherit; }
}

/* ============================================
   Animations subtiles
   ============================================ */
@media (prefers-reduced-motion: no-preference) {
    .gallery-card {
        animation: fadeIn 0.4s ease both;
    }
    .gallery-card:nth-child(2) { animation-delay: 0.05s; }
    .gallery-card:nth-child(3) { animation-delay: 0.1s; }
    .gallery-card:nth-child(4) { animation-delay: 0.15s; }
    .gallery-card:nth-child(5) { animation-delay: 0.2s; }
    .gallery-card:nth-child(6) { animation-delay: 0.25s; }

    @keyframes fadeIn {
        from { opacity: 0; transform: translateY(12px); }
        to { opacity: 1; transform: translateY(0); }
    }
}
