/* Terradoc base stylesheet — shared across all pages. */

html {
    scroll-behavior: smooth;
}
* {
    box-sizing: border-box;
}
body {
    font-family: var(--td-font-family);
    line-height: 1.6;
    margin: 0;
    padding: 0;
    background: var(--td-color-bg);
    color: var(--td-color-text);
}
.js-only {
    display: none;
}
.no-js-only {
    display: block;
}
.js .js-only {
    display: block;
}
.js .no-js-only {
    display: none;
}

/* ── Container ── */
.td-container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* ── Shadow system ── */
:root {
    --td-shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --td-shadow-md: 0 4px 12px rgba(0,0,0,0.12);
    --td-shadow-lg: 0 8px 24px rgba(0,0,0,0.16);
}

/* ── Skip link ── */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--td-color-primary);
    color: white;
    padding: 0.5rem 1rem;
    z-index: 100;
    text-decoration: none;
    border-radius: 0 0 var(--td-radius) 0;
}
.skip-link:focus {
    top: 0;
}

/* ── Navigation ── */
nav {
    background: var(--td-color-primary);
    padding: 0.75rem 0;
    margin-bottom: 0;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--td-shadow-sm);
}
nav .td-nav-inner {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 1.5rem;
}
nav a {
    color: white;
    text-decoration: none;
    padding: 0.25rem 0.5rem;
    border-radius: var(--td-radius);
    transition: background 0.2s;
}
nav a:hover, nav a.active {
    background: rgba(255,255,255,0.15);
}
nav .brand {
    font-weight: 600;
    font-size: 1.15rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}
nav .brand-logo {
    width: 36px;
    height: 36px;
    object-fit: contain;
    flex-shrink: 0;
}
nav a.active {
    background: rgba(255,255,255,0.15);
    border-bottom: 2px solid var(--td-color-accent);
}
.nav-links {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
    margin-left: auto;
    line-height: 1;
}
nav .lang-switch {
    margin-left: auto;
    display: flex;
    gap: 0.35rem;
    align-items: center;
    flex-wrap: wrap;
    font-size: 0.85rem;
}
nav .lang-link, nav .lang-current {
    padding: 0.25rem 0.5rem;
    border-radius: 999px;
}
nav .lang-link {
    color: white;
    text-decoration: none;
    opacity: 0.8;
}
nav .lang-link:hover {
    opacity: 1;
    background: rgba(255,255,255,0.15);
}
nav .lang-current {
    background: rgba(255,255,255,0.18);
    color: white;
}

/* ── Typography ── */
h1, h2, h3, h4 {
    font-family: var(--td-font-headings);
}

/* ── Header ── */
header {
    text-align: center;
    padding: 1rem 0;
    border-bottom: 2px solid var(--td-color-border);
    margin-bottom: 1.5rem;
}
h1 {
    margin: 0 0 0.5rem 0;
    color: var(--td-color-primary);
    line-height: 1.3;
}
.subtitle {
    color: var(--td-color-text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
}

/* ── Search ── */
.search-container {
    background: var(--td-color-surface);
    padding: 1rem;
    border-radius: var(--td-radius);
    border: 1px solid var(--td-color-border);
    margin-bottom: 1rem;
}
.search-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.search-input {
    flex: 1;
    min-width: 200px;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 1px solid var(--td-color-border);
    border-radius: var(--td-radius);
    outline: none;
    transition: border-color 0.2s;
}
.search-input:focus {
    border-color: var(--td-color-accent);
    box-shadow: 0 0 0 2px var(--td-color-accent-ring);
}
.filter-select {
    padding: 0.75rem;
    font-size: 1rem;
    border: 1px solid var(--td-color-border);
    border-radius: var(--td-radius);
    background: var(--td-color-surface);
    cursor: pointer;
}
.stats {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--td-color-text-muted);
}

/* ── Results ── */
.results-container {
    background: var(--td-color-surface);
    border-radius: var(--td-radius);
    border: 1px solid var(--td-color-border);
    overflow: hidden;
}
.empty-state {
    padding: 3rem;
    text-align: center;
    color: var(--td-color-text-muted);
}
.empty-state h2 {
    margin: 0 0 0.5rem 0;
    color: var(--td-color-text-muted);
}
.empty-state svg {
    display: block;
    margin: 0 auto 1rem auto;
    opacity: 0.4;
}

/* ── Loading skeleton ── */
.loading-state {
    padding: 3rem;
    text-align: center;
    color: var(--td-color-text-muted);
}
.skeleton {
    background: linear-gradient(90deg,
        var(--td-color-border-light) 25%,
        var(--td-color-bg-light) 50%,
        var(--td-color-border-light) 75%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    border-radius: var(--td-radius);
}
.skeleton-line {
    height: 1rem;
    margin-bottom: 0.75rem;
}
.skeleton-line:last-child {
    width: 60%;
}
.skeleton-block {
    height: 4rem;
    margin-bottom: 1rem;
}
@keyframes skeleton-pulse {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── Entries ── */
.entry {
    padding: 1rem;
    border-bottom: 1px solid var(--td-color-border-light);
}
.entry:last-child {
    border-bottom: none;
}
.entry:hover {
    background: var(--td-color-bg-light);
}
.entry-header {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.25rem;
}
.entry-word {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--td-color-primary);
}
.entry-secondary {
    color: var(--td-color-text-muted);
    font-size: 1rem;
}
.entry-ipa {
    color: var(--td-color-text-muted);
    font-family: var(--td-font-mono);
}
.entry-tag {
    font-size: 0.75rem;
    background: var(--td-color-bg-light);
    color: var(--td-color-accent-muted);
    padding: 0.15rem 0.5rem;
    border-radius: var(--td-radius);
    font-weight: 500;
}
.entry-definition {
    margin: 0.5rem 0;
    color: var(--td-color-text-secondary);
}
.entry-example {
    margin: 0.5rem 0;
    padding-left: 1rem;
    border-left: 3px solid var(--td-color-accent);
    color: var(--td-color-text-secondary);
    font-style: italic;
}
.entry-scientific {
    font-style: italic;
    color: var(--td-color-text-muted);
    font-size: 0.9rem;
}
.entry-comment {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: var(--td-color-warning-bg);
    border-radius: var(--td-radius);
    font-size: 0.9rem;
    color: var(--td-color-text-muted);
}
.entry-media {
    display: flex;
    gap: 1rem;
    margin-top: 0.75rem;
    align-items: flex-start;
}
.entry-thumbnail {
    max-width: 120px;
    max-height: 90px;
    border-radius: var(--td-radius);
    object-fit: cover;
    cursor: pointer;
    transition: transform 0.2s;
}
.entry-thumbnail:hover {
    transform: scale(1.05);
}
.entry-links {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.entry-links a {
    font-size: 0.85rem;
    color: var(--td-color-accent);
    text-decoration: none;
}
.entry-links a:hover {
    text-decoration: underline;
}
.highlight {
    background: var(--td-color-highlight);
    padding: 0 2px;
    border-radius: 2px;
}

/* ── Footer ── */
footer {
    margin-top: 3rem;
    padding: 2rem 0;
    text-align: center;
    font-size: 0.85rem;
    color: var(--td-color-text-muted);
    background: var(--td-color-bg-light);
    border-top: 1px solid var(--td-color-border);
}
footer p {
    margin: 0.25rem 0;
}
footer .footer-text {
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    color: var(--td-color-text-secondary);
}
footer .td-container {
    padding: 0 1.5rem;
}
footer a {
    color: var(--td-color-accent);
    text-decoration: none;
}
footer a:hover {
    text-decoration: underline;
}

/* ── Page transition ── */
main.td-container {
    animation: fadeIn 0.3s ease-out;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Focus styles ── */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
.word-item:focus-visible {
    outline: 2px solid var(--td-color-accent);
    outline-offset: 2px;
}

/* ── Cards (shared shadow behavior) ── */
.platform-card,
.portal-section,
.showcase-card {
    box-shadow: var(--td-shadow-sm);
    transition: box-shadow 0.2s, border-color 0.2s, transform 0.2s;
}
.platform-card:hover,
.portal-section:hover {
    box-shadow: var(--td-shadow-md);
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .nav-toggle {
        display: block;
    }
    .nav-links {
        display: none;
        flex-direction: column;
        width: 100%;
        gap: 0;
        padding-top: 0.5rem;
    }
    .nav-links.open {
        display: flex;
    }
    .nav-links a {
        padding: 0.5rem 0.75rem;
        width: 100%;
        border-radius: 0;
    }
    nav .td-nav-inner {
        flex-wrap: wrap;
    }
    nav .lang-switch {
        width: 100%;
        justify-content: center;
        padding-top: 0.5rem;
        border-top: 1px solid rgba(255,255,255,0.1);
        margin-top: 0.25rem;
    }
}
@media (max-width: 768px) and (min-width: 601px) {
    .td-container {
        padding: 0 1.25rem;
    }
}
@media (max-width: 600px) {
    .search-row {
        flex-direction: column;
    }
    .search-input, .filter-select {
        width: 100%;
    }
    .entry-thumbnail {
        max-width: 80px;
    }
    .td-container {
        padding: 0 1rem;
    }
}
@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
}

/* ── Print ── */
@media print {
    nav, footer, .skip-link, .nav-toggle, .lang-switch,
    .search-container, .dict-controls, .letter-bar,
    .back-link, .filter-select {
        display: none !important;
    }
    body {
        background: white;
        color: black;
        font-size: 12pt;
    }
    .td-container {
        max-width: 100%;
        padding: 0;
    }
    main.td-container {
        animation: none;
    }
    a {
        color: inherit;
        text-decoration: underline;
    }
    .entry, .platform-card, .portal-section, .showcase-card {
        box-shadow: none !important;
        border-color: #ccc !important;
    }
    .infobox {
        float: right;
        border: 1px solid #ccc;
    }
    .highlight {
        background: none;
        font-weight: bold;
    }
}
