:root {
    --primary: #111827;
    --accent: #2563eb;
    --accent-dark: #1d4ed8;
    --card-bg: #ffffff;
    --border: #e5e7eb;
    --highlight: #fff3b0;

    /* ── Semantic tokens (Day mode) ── */
    --bg-gradient: linear-gradient(135deg, #eef2ff, #f8fafc);
    --bg-surface: #f9fafb;       /* input, textarea bg */
    --bg-surface-2: #f3f4f6;     /* table header, hover */
    --text-secondary: #6b7280;   /* testi grigi secondari */
    --text-muted: #9ca3af;       /* footer, placeholder */
    --text-label: #374151;       /* label form */
    --footer-bg: #ffffff;
    --link-color: #2563eb;
    --radius-card: 20px;
    --radius-btn: 10px;
    --radius-input: 10px;
    --shadow-card: 0 25px 50px rgba(0, 0, 0, 0.08);
    --shadow-light: 0 6px 18px rgba(0, 0, 0, 0.06);
}

/* ── Dark mode overrides ── */
[data-theme="dark"] {
    --bg-gradient: #0f172a;
    --bg-surface: #334155;
    --bg-surface-2: #475569;
    --primary: #f1f5f9;
    --card-bg: #1e293b;
    --border: #334155;
    --text-secondary: #94a3b8;
    --text-muted: #9ca3af;
    --text-label: #cbd5e1;
    --footer-bg: #1f2937;
    --link-color: #60a5fa;
    --shadow-card: 0 25px 50px rgba(0, 0, 0, 0.4);
    --shadow-light: 0 6px 18px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
}

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    color: var(--primary);
}

[data-theme="dark"] table {
    background: var(--card-bg);
}

[data-theme="dark"] .card {
    border-color: var(--border);
}

[data-theme="dark"] .seo-content {
    color: var(--text-secondary);
    border-top-color: var(--border);
}

[data-theme="dark"] .seo-divider {
    border-top-color: var(--border);
}

* {
    box-sizing: border-box;
}

html {
    height: 100%;
    margin: 0;
    -webkit-text-size-adjust: 100%; /* prevent iOS Safari font inflation on rotation */
    text-size-adjust: 100%;
}

body {
    margin: 0;
}

body {
    font-family: "Inter", sans-serif;
    background: var(--bg-gradient);
    color: var(--primary);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ===== Layout ===== */

.page-content {
    flex: 1;
    padding: 50px 20px 20px;
}

.container {
    max-width: 900px;
    margin: auto;
}

.top-nav {
    max-width: 900px;
    margin: 20px auto 0;
    padding: 0 20px;
}

.top-nav a {
    text-decoration: none;
    font-weight: 600;
    color: var(--link-color);
}

/* ===== Titoli ===== */

h1 {
    text-align: center;
    font-size: clamp(22px, 4vw, 30px);
    margin-bottom: 40px;
}

/* ===== Card ===== */

.card {
    background: var(--card-bg);
    padding: 35px;
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    margin-bottom: 40px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

/* ===== FORM ===== */

form {
    max-width: 420px;
    margin: auto;
}

label {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    display: block;
    color: var(--text-label);
    white-space: nowrap; /*Aggiunto per Fix Android*/
}

/* === OLD CSS Pre-Android Fix===
input,select{
	width:100%;
	padding:10px;
	border-radius:10px;
	border:1px solid var(--border);
	margin-bottom:14px;
	font-size:14px;
	background:#f9fafb;
}*/

/* ===== Fix Android ===== */
/* ===================================================
   ANDROID LAYOUT FIX
   Prevent label wrapping that breaks row-grid alignment
   =================================================== */
input,
select {
    width: 100%;
    padding: 10px;
    border-radius: var(--radius-input);
    border: 1px solid var(--border);
    margin-bottom: 14px;
    font-size: 14px;
    background: var(--bg-surface);
    appearance: none;
}

/* ===== BOTTONI ===== */

button {
    padding: 12px 18px;
    border: none;
    border-radius: var(--radius-btn);
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s ease;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

/* No lift per bottoni utility/modali */
.cookie-buttons button:hover,
.qa-actions button:hover {
    transform: none;
    box-shadow: none;
}

/* Pairings button */
#pairingsForm button {
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: #fff;
}

/* ===== Button row ===== */

.button-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 15px;
}

/* ===== TABELLA GENERICA ===== */

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    text-align: center;
    background: white;
}

th,
td {
    padding: 14px;
    border-bottom: 1px solid var(--border);
    font-size: 16px;
}

th {
    font-weight: 700;
}

tbody tr:hover {
    background-color: var(--bg-surface);
}

/* ===== Highlight ===== */

.highlight {
    background-color: var(--highlight) !important;
    font-weight: 700;
}

.highlight td {
    background-color: var(--highlight) !important;
}

/* ===== King icons ===== */

.king-icon {
    display: block;
    font-size: 64px;
    line-height: 1;
}

.color-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-top: 6px;
}

/* ===== Footer ===== */

footer {
    text-align: center;
    padding: 20px 20px;
    border-top: 1px solid var(--border);
    background: var(--footer-bg);
    color: var(--text-muted);
    font-size: 14px;
    position: relative;
}

/* ===== Theme Toggle ===== */

.theme-toggle {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    line-height: 1;
    transition: background 0.2s ease;
}

.theme-toggle:hover {
    background: rgba(128, 128, 128, 0.15);
    transform: translateY(-50%);
    box-shadow: none;
}

/* ===== Mobile fine tuning ===== */

@media (max-width: 480px) {
    .page-content {
        padding: 10px 14px 5px !important;
    }

    .hero-container {
        padding-top: 0;
    }
}

/* ============================= */
/* Shared Internal Header        */
/* ============================= */

.internal-header {
    margin-top: 38px;
    margin-bottom: 24px;
}

.internal-title-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
}

.internal-logo {
    width: 90px;
    height: 90px;
    object-fit: contain;
}

.internal-header h1 {
    font-size: 32px;
    font-weight: 700;
    margin: 0;
}

@media (max-width: 480px) {
    .internal-title-wrapper {
        flex-direction: column;
        gap: 12px;
    }

    .internal-logo {
        width: 70px;
        height: 70px;
    }

    .internal-header h1 {
        font-size: 24px;
    }
}

/* ===== Footer Version ===== */

.footer-version {
    font-size: 12px;
    color: var(--text-muted);
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
}

.footer-links a:hover {
    text-decoration: underline;
}

/* ============================= */
/* Footer Layout                 */
/* ============================= */

.footer-inner {
    margin-top: 10px;
}

.footer-copy {
    font-size: 14px;
}

.footer-links {
    margin-top: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
}

.footer-links a:hover {
    text-decoration: underline;
}

.footer-row {
    display: inline;
}

.footer-social-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    color: var(--text-secondary);
    padding: 2px;
    border-radius: 6px;
    transition: color 0.2s ease, background 0.2s ease;
}

.footer-social-link:hover {
    color: var(--text-label);
    background: rgba(128, 128, 128, 0.15);
    text-decoration: none;
}

/* Mobile */

@media (max-width: 480px) {
    .footer-links {
        display: flex;
        flex-direction: column;
        gap: 4px;
        align-items: center;
    }

    .footer-row {
        display: flex;
        gap: 6px;
        justify-content: center;
    }
}

.footer-row {
    display: flex;
    gap: 6px;
}

.footer-copy {
    font-size: 14px;
    line-height: 1.5;
}

@media (max-width: 768px) {
    .page-content {
        flex: 1;
    }
}

.seo-content {
    max-width: 650px;
    margin: 5px auto 10px auto;
    padding-top: 15px;
    border-top: 1px solid #e6e6e6;
    font-size: 0.9rem;
    line-height: 1.6;
    color: #666;
}

.seo-content h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 10px;
}
@media (max-width: 768px) {
    .seo-content {
        padding-left: 20px;
        padding-right: 20px;
    }
}

.seo-divider {
    border: none;
    border-top: 1px solid #e6e6e6;
    padding-top: 15px;
    margin-top: 15px;
}

.seo-jump {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-decoration: none;
}

.seo-jump:hover {
    text-decoration: underline;
}

.chessflow-promo {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #e6e6e6;
    font-size: 0.9rem;
    line-height: 1.6;
    color: #666;
}

[data-theme="dark"] .chessflow-promo {
    border-top-color: rgba(255, 255, 255, 0.1);
}

.chessflow-promo a {
    color: var(--link-color);
    font-weight: 600;
    text-decoration: none;
}

.chessflow-promo a:hover {
    text-decoration: underline;
}

.seo-jump-wrapper {
    text-align: right;
    margin-top: 15px;
}

@media (max-width: 480px) {
    .card {
        padding: 18px 12px;
    }

    .result-box {
        margin-right: -12px;
        width: calc(100% + 24px);
        padding: 22px 16px;
    }
}

.cta-wrapper {
    text-align: center;
    margin-top: 35px;
    margin-bottom: 60px;
}

@media (max-width: 480px) {
    .cta-wrapper {
        margin-bottom: 90px;
    }
}

footer {
    margin-top: auto;
}

.page-content {
    padding-bottom: 80px;
}

@media (max-width: 480px) {
    .page-content {
        padding-bottom: 120px;
    }
}

/* ===== Input + copy button ===== */

.input-copy-wrap {
    position: relative;
    width: 100%;
}

.input-copy-wrap input {
    padding-right: 64px;
    margin-bottom: 0;
}

.input-copy-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-surface-2);
    color: var(--text-secondary);
    cursor: pointer;
    transition: 0.15s;
    margin-bottom: 0;
}

.input-copy-btn:hover {
    transform: translateY(-50%);
    box-shadow: none;
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

textarea {
    width: 100%;
    padding: 10px;
    border-radius: var(--radius-input);
    border: 1px solid var(--border);
    margin-bottom: 14px;
    font-size: 14px;
    background: var(--bg-surface);
    resize: vertical;
}
#cookie-banner {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
}

.cookie-panel {
    background: #ffffff;
    width: 100%;
    max-width: 720px;
    padding: 24px 28px;
    border-radius: 18px;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.18);
}

.cookie-panel p {
    margin: 0 0 18px;
    font-size: 14px;
    line-height: 1.6;
    color: #374151;
}

.cookie-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.cookie-buttons button {
    padding: 8px 16px;
    font-size: 14px;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
}

#acceptCookies {
    background: #2563eb;
    color: white;
}

#rejectCookies {
    background: #e5e7eb;
    color: #111827;
}

/* ---- STICKY TOOLS NAV (global) ---- */

.tools-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.07);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.tools-nav-inner {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.tools-nav-inner::-webkit-scrollbar { display: none; }

.tools-nav-link {
    flex: 0 0 auto;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    text-decoration: none;
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    transition: all 0.15s;
    white-space: nowrap;
}

.tools-nav-link:hover {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

.tools-nav-link.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

[data-theme="dark"] .tools-nav {
    background: rgba(17, 24, 39, 0.92);
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .tools-nav-link {
    color: #d1d5db;
    border-color: #374151;
    background: #1f2937;
}

[data-theme="dark"] .tools-nav-link:hover,
[data-theme="dark"] .tools-nav-link.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

@media (max-width: 600px) {
    .tools-nav-inner {
        justify-content: flex-start;
        padding: 8px 12px;
    }
}

@media (min-width: 769px) {
    .tools-nav {
        display: none;
    }
}

/* ===== App Store CTA ===== */

.app-cta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin: 30px 0 40px;
    padding: 24px 28px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-light);
    text-decoration: none;
    color: inherit;
}

/* display:flex batterebbe l'attributo hidden */
.app-cta[hidden] {
    display: none;
}

.app-cta strong {
    display: block;
    margin-bottom: 6px;
    font-size: 16px;
    color: var(--primary);
}

.app-cta p {
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-secondary);
}

.app-cta-badge {
    flex: 0 0 auto;
    width: 120px;
    height: 40px;
}

.app-cta-badge-dark {
    display: none;
}

[data-theme="dark"] .app-cta-badge-light {
    display: none;
}

[data-theme="dark"] .app-cta-badge-dark {
    display: block;
}

@media (max-width: 480px) {
    .app-cta {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
        padding: 20px;
    }
}
