/* Theme variables - light (default) */
:root {
    --bg: #fff;
    --bg-alt: #f8f8f8;
    --card-bg: #f0f0f0;
    --text: #333;
    --text-muted: #555;
    --text-faint: #595959;
    --text-faintest: #6b6b6b;
    --link: #0066cc;
    --link-hover: #0052a3;
    --border: #ddd;
    --border-light: #eee;
    --card-hover: rgba(0,0,0,0.1);
    --badge-bg: #eee;
    --badge-text: #555;
    --badge-eol-bg: #fdd;
    --badge-eol-text: #900;
    --btn-bg: #0066cc;
    --btn-hover: #0052a3;
    --btn-text: #fff;
    --input-border: #ccc;
    --share-bg: #eee;
    --share-border: #ccc;
    --share-text: #555;
    --version-bg: #f8f8f8;
    --tryit-bg: #1a1a2e;
    --tryit-text: #eee;
    --success: #007a00;
    --error: #b30000;
    --accent: #0066cc;
    --action-bg: #0f766e;
    --action-hover: #115e59;
    --action-text: #fff;
}

/* Dark mode */
[data-theme="dark"] {
    --bg: #1a1a2e;
    --bg-alt: #232340;
    --card-bg: #232340;
    --text: #e0e0e0;
    --text-muted: #c8c8c8;
    --text-faint: #b0b0b0;
    --text-faintest: #a0a0a0;
    --link: #5cacee;
    --link-hover: #7dc0ff;
    --border: #3a3a5c;
    --border-light: #2e2e4a;
    --card-hover: rgba(255,255,255,0.05);
    --badge-bg: #2e2e4a;
    --badge-text: #b0b0b0;
    --badge-eol-bg: #4a2020;
    --badge-eol-text: #ff9a9a;
    --btn-bg: #5cacee;
    --btn-hover: #7dc0ff;
    --btn-text: #1a1a2e;
    --input-border: #3a3a5c;
    --share-bg: #2e2e4a;
    --share-border: #3a3a5c;
    --share-text: #b0b0b0;
    --version-bg: #232340;
    --tryit-bg: #0e0e1a;
    --tryit-text: #e0e0e0;
    --success: #6bd66b;
    --error: #ff7b7b;
    --accent: #5cacee;
    --action-bg: #14b8a6;
    --action-hover: #2dd4bf;
    --action-text: #0e0e1a;
}

/* Accessibility */
.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; }
.skip-link { position: absolute; top: -40px; left: 0; background: var(--btn-bg); color: var(--btn-text); padding: 8px 16px; z-index: 100; text-decoration: none; border-radius: 0 0 4px 0; }
.skip-link:focus { top: 0; }
/* WCAG 2.4.7 Focus Visible: every keyboard-focused interactive element gets a
   visible 2px outline regardless of browser default. Mouse focus (which does
   not match :focus-visible in modern browsers) keeps the default behavior so
   the ring isn't shown when clicking. The accent color is theme-aware. */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, summary:focus-visible, [tabindex]:focus-visible,
[role="button"]:focus-visible, [role="link"]:focus-visible {
    outline: 2px solid var(--link);
    outline-offset: 2px;
    border-radius: 2px;
}

@font-face { font-family: 'OCR A Extended Local'; src: local('OCR A Extended'); font-weight: normal; font-style: normal; }

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; line-height: 1.6; color: var(--text); background: var(--bg); max-width: 1200px; margin: 0 auto; padding: 0 20px; }
header nav { display: flex; justify-content: space-between; align-items: center; padding: 1rem 0; border-bottom: 1px solid var(--border); margin-bottom: 2rem; }
.site-name, h1, h2 { font-family: 'OCR A Extended Local', monospace; }
.site-name { font-size: 1.4rem; font-weight: bold; text-decoration: none; color: var(--text); display: flex; align-items: center; gap: 0.4rem; }
.site-logo { border-radius: 4px; object-fit: contain; }
.nav-links a { margin-left: 1.5rem; text-decoration: none; color: var(--link); }
.auth-status { margin-left: 1.5rem; color: var(--success); font-size: 0.9rem; }
main { min-height: 60vh; }
.breadcrumb { font-size: 0.85rem; color: var(--text-faint); margin-bottom: 1.5rem; }
.breadcrumb a { color: var(--link); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
footer { margin-top: 3rem; padding: 1rem 0; border-top: 1px solid var(--border); text-align: center; font-size: 0.85rem; color: var(--text-faint); }
footer a { color: var(--text-faint); }
.disclaimer { font-size: 0.75rem; color: var(--text-faintest); margin-top: 0.5rem; max-width: 600px; margin-left: auto; margin-right: auto; line-height: 1.5; }
a { color: var(--link); }
a:hover { color: var(--link-hover); }

/* Theme toggle */
.theme-toggle { background: none; border: 1px solid var(--border); border-radius: 4px; padding: 4px 8px; cursor: pointer; color: var(--text-muted); font-size: 1rem; margin-left: 1rem; vertical-align: middle; }
.theme-toggle:hover { color: var(--text); border-color: var(--text-muted); }

/* Catalog */
.category-group { margin-bottom: 2rem; }
.category-group h2 { font-size: 1.2rem; border-bottom: 2px solid var(--accent); padding-bottom: 0.3rem; margin-bottom: 1rem; }
.program-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.program-card { border: 1px solid var(--border); border-radius: 6px; padding: 1rem; transition: box-shadow 0.15s; background: var(--bg); }
.program-card:hover { box-shadow: 0 2px 8px var(--card-hover); }
.program-card a { text-decoration: none; color: inherit; }
.program-card .card-header { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; }
.program-card .card-header img { width: 32px; height: 32px; object-fit: contain; }
.program-card .card-header h3 { font-size: 1rem; margin: 0; }
.program-card .card-desc { font-size: 0.85rem; color: var(--text-muted); }
.badge { display: inline-block; font-size: 0.7rem; padding: 2px 6px; border-radius: 3px; background: var(--badge-bg); color: var(--badge-text); margin-left: 0.5rem; }
.badge-eol { background: var(--badge-eol-bg); color: var(--badge-eol-text); }

/* Program page */
.program-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; }
.program-header img { width: 64px; height: 64px; object-fit: contain; }
.share-btn { font-size: 0.5em; font-weight: normal; padding: 2px 8px; margin-left: 0.5rem; vertical-align: middle; background: var(--share-bg); border: 1px solid var(--share-border); border-radius: 3px; cursor: pointer; color: var(--share-text); text-decoration: none; }
.share-btn:hover { background: var(--border); color: var(--text); }
.program-meta { margin-bottom: 2rem; }
.program-meta dt { font-weight: bold; float: left; width: 120px; }
.program-meta dd { margin-left: 130px; margin-bottom: 0.3rem; }
.links-list a { display: inline-block; margin-right: 1rem; color: var(--link); }
h2, h3 { position: relative; }
.anchor-link { position: absolute; left: -1.5em; padding-right: 0.5em; font-weight: normal; color: var(--text-faintest); text-decoration: none; opacity: 0; transition: opacity 0.15s; }
.anchor-link:hover { color: var(--link); }
h2:hover .anchor-link, h3:hover .anchor-link { opacity: 1; }
.platform-icons i { font-size: 1.2rem; margin-right: 0.4rem; color: var(--text-muted); }
.version-info { background: var(--version-bg); padding: 1rem; border-radius: 6px; margin-bottom: 2rem; }
.demo-list { list-style: none; }
.demo-list li { padding: 0.5rem 0; border-bottom: 1px solid var(--border-light); }
.demo-locked { opacity: 0.5; }
.demo-locked::after { content: " (agree to terms first)"; font-size: 0.8rem; color: var(--text-faintest); }
.demo-switcher-wrap { position: relative; display: inline; }
.demo-switcher { position: absolute; top: 100%; left: 0; z-index: 50; background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 0.5rem 0.75rem; font-size: 0.85rem; white-space: nowrap; box-shadow: 0 3px 8px rgba(0,0,0,0.15); }
.demo-switcher a, .demo-switcher span { display: block; padding: 0.3rem 0; }
.demo-switcher a { color: var(--link); text-decoration: none; }
.demo-switcher a:hover { text-decoration: underline; }
.demo-switcher-current { font-weight: bold; color: var(--text); }

/* TryIt */
.tryit-result { background: var(--tryit-bg); color: var(--tryit-text); padding: 1rem; border-radius: 6px; font-family: "Cascadia Code", "Fira Code", monospace; font-size: 0.85rem; white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; }
.tryit-metrics { display: flex; gap: 2rem; margin: 1rem 0; font-size: 0.9rem; }
pre.tryit-code { border-radius: 6px; font-size: 0.85rem; max-height: 500px; }
pre.tryit-code code { white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; }
pre.command-line.tryit-code { padding-left: 1rem; }
body.modal-open { overflow: hidden; }
.html-preview-dialog { width: 95vw; max-width: 95vw; height: 95vh; max-height: 95vh; padding: 0; border: 1px solid var(--border, #ddd); border-radius: 8px; background: var(--bg, #fff); color: var(--text, #000); overflow: hidden; }
.html-preview-dialog[open] { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); margin: 0; z-index: 10000; display: flex; flex-direction: column; }
.html-preview-dialog:not([open]) { display: none; }
.html-preview-dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
.html-preview-dialog .html-preview-bar { flex: 0 0 auto; position: relative; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: 0.5rem 0.85rem; background: var(--card-bg, #2a2a3a); color: var(--text, #fff); border-bottom: 1px solid var(--border, #444); }
.html-preview-dialog .html-preview-title { font-weight: 600; font-size: 0.95rem; }
.html-preview-dialog .html-preview-bar .btn { padding: 0.35rem 0.75rem; font-size: 0.85rem; }
.html-preview-dialog .html-preview-host { flex: 1 1 auto; min-height: 0; width: 100%; background: #fff; display: block; overflow: hidden; }
.input-card { margin: 0.5rem 0 1.5rem 0; padding: 0.85rem 1rem; background: var(--card-bg, #f5f5f5); border: 1px solid var(--border, #ddd); border-radius: 6px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; transition: box-shadow 0.2s ease, transform 0.2s ease; }
.input-card .input-meta { font-family: "Cascadia Code", "Fira Code", monospace; font-size: 0.9rem; }
.input-card .input-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.input-card .input-actions .btn { padding: 0.4rem 0.85rem; font-size: 0.85rem; }
@keyframes inputFlash {
    0%   { transform: scale(1);    box-shadow: 0 0 0 0    var(--action-bg); background: var(--card-bg, #f5f5f5); }
    20%  { transform: scale(1.02); box-shadow: 0 0 0 6px  rgba(13, 148, 136, 0.35); background: rgba(13, 148, 136, 0.12); }
    60%  { transform: scale(1);    box-shadow: 0 0 0 12px rgba(13, 148, 136, 0);    background: rgba(13, 148, 136, 0.08); }
    100% { transform: scale(1);    box-shadow: 0 0 0 0    transparent;              background: var(--card-bg, #f5f5f5); }
}
.input-card.input-flash { animation: inputFlash 1.6s ease-out 1; }

/* About */
.about h2 { margin-top: 2.5rem; margin-bottom: 0.75rem; }
.about h3 { margin-top: 1.5rem; margin-bottom: 0.5rem; }
.about p { margin-bottom: 0.75rem; }
.about ul { margin: 0.75rem 0 1.25rem 2rem; }
.about li { margin-bottom: 0.4rem; }
.about hr { margin: 2.5rem 0; }

/* Terms */
.terms-box { max-width: 600px; margin: 2rem auto; padding: 2rem; border: 1px solid var(--border); border-radius: 6px; }
.terms-box h1 { font-size: 1.3rem; margin-bottom: 1rem; }
.terms-box .terms-text { margin-bottom: 1.5rem; font-size: 0.9rem; line-height: 1.7; }
.btn { display: inline-block; padding: 0.6rem 1.5rem; background: var(--btn-bg); color: var(--btn-text); border: none; border-radius: 4px; cursor: pointer; font-size: 1rem; text-decoration: none; line-height: 1.2; vertical-align: middle; box-sizing: border-box; font-family: inherit; }
.btn:hover { background: var(--btn-hover); }
.btn-secondary { background: var(--share-bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); color: var(--text); }
.btn-action { background: var(--action-bg); color: var(--action-text); border: 1px solid var(--action-bg); font-weight: 600; }
.btn-action:hover { background: var(--action-hover); border-color: var(--action-hover); color: var(--action-text); }
input[type="email"], input[type="search"] { padding: 0.5rem; border: 1px solid var(--input-border); border-radius: 4px; margin-bottom: 1rem; font-size: 1rem; background: var(--bg); color: var(--text); }
input[type="email"] { width: 100%; }

/* Examples */
.example-block { margin-bottom: 1.5rem; }
.ex-heading { font-size: 0.95rem; font-weight: 600; margin-bottom: 0.3rem; }
pre.ex-code { margin: 0; border-radius: 4px; font-size: 0.85rem; }
pre.ex-code code { white-space: pre-wrap; }
div.code-toolbar > .toolbar > .toolbar-item > button,
div.code-toolbar > .toolbar > .toolbar-item > span { font-size: 0.75rem; padding: 3px 8px; background: var(--share-bg); color: var(--text-muted); border: 1px solid var(--share-border); border-radius: 3px; cursor: pointer; }
div.code-toolbar > .toolbar > .toolbar-item > button:hover { background: var(--border); color: var(--text); }
div.code-toolbar > .toolbar > .toolbar-item > button:focus { outline: 2px solid var(--link); outline-offset: 2px; }
pre.source-view { border-radius: 6px; font-size: 0.85rem; }
pre.source-view code { white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; }

/* Help modal */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 1000; display: flex; align-items: center; justify-content: center; }
.modal-content { background: var(--bg); border-radius: 8px; width: 90%; max-width: 800px; max-height: 85vh; display: flex; flex-direction: column; box-shadow: 0 4px 20px rgba(0,0,0,0.3); }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.5rem; border-bottom: 1px solid var(--border); }
.modal-header h2 { font-size: 1.1rem; margin: 0; }
.modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-muted); padding: 0 0.5rem; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 1.5rem; overflow-y: auto; font-size: 0.9rem; line-height: 1.6; }
.modal-body pre { background: var(--bg-alt); padding: 1rem; border-radius: 4px; overflow-x: auto; white-space: pre-wrap; font-size: 0.85rem; margin: 0.75rem 0; }
.modal-body code { font-family: "Cascadia Code", "Fira Code", monospace; }
.modal-body h1 { font-size: 1.2rem; margin-bottom: 0.5rem; }
.modal-body p { margin-bottom: 0.5rem; }
