/* ==========================================================================
   ScholarshipFinder — Stylesheet
   Organization: Tokens → Base → Layout → Components → Page-specific
                 → Utilities → Media queries
   ========================================================================== */

/* ------------------------------------------------------------------ */
/* Tokens                                                             */
/* ------------------------------------------------------------------ */
:root {
    /* Brand — matches the JTOB main site's red (jtob.org/public_html) */
    --brand: #c8102e;
    --brand-700: #9d0c24;
    --brand-050: #fbe9ec;
    --accent: #0d9488;
    --accent-050: #e6f5f3;

    /* Surfaces & text */
    --bg-app: #f4f6fa;
    --surface: #ffffff;
    --surface-muted: #f6f8fa;
    --surface-sunken: #eef1f5;
    --text: #1a1f2c;
    --text-muted: #5b6470;
    --text-subtle: #6b7280;
    --border: #e2e6ec;
    --border-strong: #cdd3dc;

    /* Status (AA-safe) */
    --success: #1a7f37;
    --success-bg: #dafbe1;
    --error: #b3261e;
    --error-bg: #fdecea;
    --warning: #8a5a00;
    --warning-bg: #fff3cd;
    --info: #0d7d8a;
    --info-bg: #e0f3f5;

    /* Type scale */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-md: 1.125rem;
    --text-lg: 1.25rem;
    --text-xl: 1.5rem;
    --text-2xl: 2rem;
    --text-3xl: 2.25rem;

    /* Spacing scale */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --space-7: 3rem;
    --space-8: 4rem;

    /* Radius, shadow, sizing */
    --radius-sm: 4px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-pill: 999px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.08);
    --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.08);
    --max-width: 70rem;
    --focus-ring: 0 0 0 3px rgba(200, 16, 46, 0.35);
    --font: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

    /* Legacy aliases (existing selectors reference these) */
    --color-bg: var(--surface);
    --color-text: var(--text);
    --color-text-muted: var(--text-muted);
    --color-border: var(--border);
    --color-focus: var(--brand);
    --color-success: var(--success);
    --color-error: var(--error);
    --color-warning: var(--warning);
    --color-info: var(--brand);
    --spacing-unit: var(--space-4);
}

/* ------------------------------------------------------------------ */
/* Base                                                               */
/* ------------------------------------------------------------------ */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font);
    font-size: var(--text-base);
    line-height: 1.6;
    color: var(--text);
    background: var(--bg-app);
}

h1 {
    font-size: var(--text-2xl);
    line-height: 1.2;
    margin: 0 0 var(--space-4);
    color: var(--text);
}

h2 {
    font-size: var(--text-lg);
    line-height: 1.3;
    margin: 0 0 var(--space-3);
}

h3 {
    font-size: var(--text-md);
    margin: 0 0 var(--space-2);
}

p {
    margin: 0 0 var(--space-3);
}

a {
    color: var(--brand-700);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid var(--brand);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

strong {
    color: var(--text);
}

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    background: var(--surface-muted);
    padding: 0.1rem 0.35rem;
    border-radius: var(--radius-sm);
    font-size: 0.9em;
}

/* ------------------------------------------------------------------ */
/* Layout                                                             */
/* ------------------------------------------------------------------ */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--space-5) var(--space-4);
}

main.container {
    min-height: 60vh;
}

.skip-link {
    position: absolute;
    top: -100%;
    left: var(--space-3);
    z-index: 1000;
    padding: var(--space-2) var(--space-4);
    background: var(--brand-700);
    color: #fff;
    border-radius: var(--radius-sm);
    text-decoration: none;
    box-shadow: var(--shadow-md);
}

.skip-link:focus {
    top: var(--space-2);
}

/* Site header */
.site-header {
    background: rgba(255, 255, 255, 0.92);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--space-3) var(--space-4);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    flex-wrap: wrap;
}

.site-brand {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-weight: 700;
    font-size: var(--text-md);
    color: var(--text);
    text-decoration: none;
}

.site-brand:hover {
    text-decoration: none;
    color: var(--brand-700);
}

.site-brand .brand-logo {
    height: 2rem;
    width: auto;
    border-radius: var(--radius);
}

.site-brand .brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--brand), var(--accent));
    color: #fff;
    font-weight: 800;
    font-size: var(--text-sm);
}

.site-header nav {
    flex: 1 1 auto;
}

.nav-links {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
    justify-content: flex-end;
    align-items: center;
}

.nav-links li {
    margin: 0;
}

.nav-links a,
.nav-links button {
    display: inline-flex;
    align-items: center;
    padding: var(--space-2) var(--space-3);
    color: var(--text);
    text-decoration: none;
    border-radius: var(--radius-pill);
    border: 2px solid transparent;
    min-height: 44px;
    font-size: var(--text-base);
    font-weight: 600;
    background: none;
    cursor: pointer;
    font-family: inherit;
}

.nav-links a:hover,
.nav-links button:hover {
    background: var(--brand-050);
    color: var(--brand-700);
    text-decoration: none;
}

.nav-links a[aria-current="page"] {
    color: #fff;
    font-weight: 700;
    background: var(--brand);
}

/* Link back to the JTOB main site — visually distinct from this app's own nav */
.nav-links a.nav-back {
    color: var(--text-muted);
    font-weight: 700;
    border-color: var(--border-strong);
}

.nav-links a.nav-back:hover {
    color: var(--brand-700);
    border-color: var(--brand);
    background: var(--brand-050);
}

.nav-links form {
    margin: 0;
}

/* Nav toggle (hidden on desktop) */
.nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text);
}

.nav-toggle:hover {
    background: var(--surface-muted);
}

.nav-toggle .nav-toggle-icon,
.nav-toggle .nav-toggle-icon::before,
.nav-toggle .nav-toggle-icon::after {
    content: "";
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    position: relative;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.nav-toggle .nav-toggle-icon::before {
    position: absolute;
    top: -6px;
}

.nav-toggle .nav-toggle-icon::after {
    position: absolute;
    top: 6px;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-icon {
    background: transparent;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-icon::before {
    transform: translateY(6px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] .nav-toggle-icon::after {
    transform: translateY(-6px) rotate(-45deg);
}

.nav-toggle-text {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* Site footer */
.site-footer {
    text-align: center;
    padding: var(--space-5) var(--space-4);
    font-size: var(--text-sm);
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    margin-top: var(--space-6);
    background: var(--surface-muted);
}

.site-footer a {
    color: var(--text-muted);
}

.footer-tagline {
    margin-top: var(--space-1);
    font-size: var(--text-xs);
    color: var(--text-muted);
}

/* ------------------------------------------------------------------ */
/* Components                                                         */
/* ------------------------------------------------------------------ */

/* Buttons */
button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    min-height: 44px;
    font-size: var(--text-base);
    font-family: inherit;
    line-height: 1.2;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

button:hover,
.button:hover {
    background: var(--surface-muted);
    border-color: var(--border-strong);
    text-decoration: none;
}

.button.small {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
    min-height: 36px;
}

.button.primary-action {
    background-color: var(--brand-700);
    border-color: var(--brand-700);
    color: #fff;
    padding: var(--space-3) var(--space-5);
    font-size: var(--text-md);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

.button.primary-action:hover {
    background-color: #083779;
    border-color: #083779;
}

/* Buttons on dark/tinted backgrounds stay readable */
.button.primary-action:focus-visible {
    outline: 3px solid rgba(255, 255, 255, 0.9);
    outline-offset: 2px;
    box-shadow: 0 0 0 5px var(--brand);
}

/* Badges */
.section-badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: var(--radius-pill);
    font-size: var(--text-xs);
    font-weight: 700;
    line-height: 1.4;
    white-space: nowrap;
    letter-spacing: 0.02em;
    background: var(--brand-050);
    color: var(--brand-700);
    border: 1px solid #cfe0fb;
}

/* In the table the column is too narrow to hold the longest label on one
   line, so there it wraps instead of overflowing. */
.scholarship-table .section-badge {
    white-space: normal;
}

/* Cards (shared treatment) */
#filter-panel,
.filter-controls {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

/* Forms */
form p {
    margin: 0 0 var(--space-4);
}

form label {
    display: block;
    font-weight: 600;
    margin-bottom: var(--space-1);
    color: var(--text);
}

form input,
form select,
form textarea,
.form-field input,
.filter-field input,
.filter-field select,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
select,
textarea {
    width: 100%;
    max-width: 32rem;
    padding: var(--space-3) var(--space-3);
    font-size: var(--text-base);
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    line-height: 1.4;
}

input::placeholder,
textarea::placeholder {
    color: var(--text-subtle);
}

input[readonly] {
    background-color: var(--surface-sunken);
    color: var(--text-muted);
    cursor: not-allowed;
}

textarea {
    min-height: 120px;
    resize: vertical;
}

form input:focus,
form select:focus,
form textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: var(--focus-ring);
}

.errorlist {
    list-style: none;
    margin: var(--space-1) 0 0;
    padding: 0;
    color: var(--error);
    font-size: var(--text-sm);
}

.errorlist li {
    margin-bottom: var(--space-1);
}

.form-group,
.form-field {
    margin-bottom: var(--space-4);
}

.form-group textarea {
    min-height: 100px;
    resize: vertical;
}

.form-actions,
.action-buttons {
    display: flex;
    gap: var(--space-3);
    margin-top: var(--space-4);
    flex-wrap: wrap;
}

/* ------------------------------------------------------------------ */
/* Page-specific                                                     */
/* ------------------------------------------------------------------ */

/* Home hero */
.hero {
    background: linear-gradient(135deg, var(--brand-050), var(--accent-050));
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-7) var(--space-5);
    margin-bottom: var(--space-6);
    box-shadow: var(--shadow-sm);
}

.hero h1 {
    margin-bottom: var(--space-3);
}

.hero-sub {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--brand-600);
    margin-bottom: var(--space-2);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.hero p {
    font-size: var(--text-md);
    color: var(--text-muted);
    max-width: 42rem;
    margin-bottom: var(--space-5);
}

.hero-actions {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

/* Home page counts by section */
.hero-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--space-4);
    margin-top: var(--space-5);
}

.hero-stat {
    padding: var(--space-4);
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.hero-stat-number {
    margin: 0;
    font-size: var(--text-2xl);
    font-weight: 800;
    line-height: 1.1;
    color: var(--brand-700);
}

.hero-stat-label {
    margin: var(--space-1) 0 0;
    font-size: var(--text-sm);
    color: var(--text-muted);
}

.footer-meta {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

/* Language switcher */
.lang-switch {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.lang-switch li + li::before {
    content: "";
    display: inline-block;
    width: 1px;
    height: 0.9em;
    margin-right: var(--space-1);
    vertical-align: -0.05em;
    background: var(--border-strong);
}

.lang-switch a {
    display: inline-block;
    padding: var(--space-1) var(--space-2);
    font-size: var(--text-sm);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
}

.lang-switch a:hover {
    color: var(--text);
    background: var(--surface-muted);
    text-decoration: none;
}

.lang-switch a.is-current {
    color: var(--brand-700);
    font-weight: 700;
}

.result-empty {
    margin: var(--space-4) 0;
    color: var(--text-muted);
}

.hero-actions .button {
    width: 100%;
    max-width: 22rem;
}

/* Scholarship list — filter panel */
.filter-toggle {
    margin-bottom: var(--space-3);
    padding: var(--space-3) var(--space-5);
    background: var(--text);
    color: #fff;
    border: 1px solid var(--text);
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    font-size: var(--text-base);
}

.filter-toggle:hover {
    background: #2d3340;
    border-color: #2d3340;
}

#filter-panel {
    margin-bottom: var(--space-5);
    padding: var(--space-4);
}

.filter-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}

.filter-field label {
    font-weight: 600;
    font-size: var(--text-sm);
    margin-bottom: var(--space-1);
    display: block;
}

.filter-field input,
.filter-field select {
    width: 100%;
    max-width: 100%;
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
}

.qualifier-details {
    margin-bottom: var(--space-3);
    font-size: var(--text-sm);
}

.qualifier-details summary {
    cursor: pointer;
    font-weight: 600;
    padding: var(--space-2) 0;
}

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    padding: var(--space-3);
    background: var(--surface-muted);
    border-radius: var(--radius-sm);
}

.checkbox-group label {
    font-weight: 400;
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    white-space: nowrap;
}

.filter-actions {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.filter-actions button,
.filter-actions .button {
    font-size: var(--text-sm);
    padding: var(--space-2) var(--space-4);
}

/* Award amount filter */
.award-min-filter {
    max-width: 24rem;
}

.award-min-filter .help-text {
    display: block;
    margin-top: var(--space-1);
    font-size: var(--text-xs);
    color: var(--text-muted);
}

/* Filter controls (admin requests) */
.filter-controls {
    margin-bottom: var(--space-5);
    padding: var(--space-4);
}

.filter-form {
    display: flex;
    gap: var(--space-3);
    align-items: end;
    flex-wrap: wrap;
}

.filter-form label {
    margin-bottom: 0;
    font-size: var(--text-sm);
    font-weight: 600;
}

.filter-form select {
    width: auto;
    max-width: 12rem;
}

/* Scholarship table (desktop) */
.table-wrapper {
    overflow-x: auto;
    margin-top: var(--space-4);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    -webkit-overflow-scrolling: touch;
}

.scholarship-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
    background: var(--surface);
}

.scholarship-table th {
    text-align: left;
    padding: var(--space-3) var(--space-3);
    font-weight: 700;
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    background: var(--surface-muted);
    border-bottom: 2px solid var(--border-strong);
    white-space: nowrap;
}

.scholarship-table td {
    padding: var(--space-3);
    border-bottom: 1px solid var(--border);
    vertical-align: top;
    word-break: break-word;
}

.scholarship-table tbody tr:last-child td {
    border-bottom: none;
}

.scholarship-table tbody tr:hover {
    background: var(--surface-muted);
}

.scholarship-table a {
    font-weight: 600;
    color: var(--brand-700);
    text-decoration: none;
}

.scholarship-table a:hover {
    text-decoration: underline;
}

.result-count {
    margin-top: var(--space-3);
    font-size: var(--text-sm);
    color: var(--text-muted);
}

/* Text clamp (used in list + detail) */
.text-clamp {
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    max-height: 4.8em;
    transition: max-height 0.3s ease;
    position: relative;
}

/* Clamping depends on a script to expand it again, so without JS show the
   text in full rather than truncating it with no way out. */
html:not(.js) .text-clamp {
    display: block;
    -webkit-line-clamp: unset;
    line-clamp: unset;
    max-height: none;
    overflow: visible;
}

/* Revealed by filters.js only where the text actually overflows. */
.clamp-toggle[hidden],
html:not(.js) .clamp-toggle {
    display: none;
}

.text-clamp.expanded {
    -webkit-line-clamp: unset;
    line-clamp: unset;
    max-height: none;
}

.clamp-toggle {
    display: inline-block;
    margin-top: var(--space-1);
    padding: 0;
    min-height: 0;
    font-size: var(--text-sm);
    color: var(--brand-700);
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.clamp-toggle:hover {
    color: var(--brand-700);
    background: none;
    border: none;
}

/* Eligibility notice — every listing here is open to Turkish students */
.notice {
    margin: var(--space-5) 0;
    padding: var(--space-4) var(--space-5);
    background: var(--accent-050);
    border: 1px solid #bfe3de;
    border-left: 4px solid var(--accent);
    border-radius: var(--radius);
}

.notice-title {
    margin: 0 0 var(--space-1);
    font-weight: 700;
    color: #0b6b62;
}

.notice-title::before {
    content: "✓";
    display: inline-block;
    margin-inline-end: var(--space-2);
    font-weight: 800;
}

.notice-body {
    margin: 0;
    font-size: var(--text-sm);
    color: var(--text);
    max-width: 60ch;
}

.open-badge {
    display: inline-block;
    padding: 2px var(--space-3);
    font-size: var(--text-xs);
    font-weight: 700;
    line-height: 1.6;
    color: #0b6b62;
    background: var(--accent-050);
    border: 1px solid #bfe3de;
    border-radius: var(--radius-pill);
    white-space: nowrap;
}

.open-badge::before {
    content: "✓";
    margin-inline-end: var(--space-1);
}

/* The source wording, under a translated value */
.source-original {
    margin: var(--space-1) 0 0;
    font-size: var(--text-xs);
    line-height: 1.5;
    color: var(--text-subtle);
}

.source-original-label {
    font-weight: 600;
}

/* Scholarship detail */
.scholarship-detail-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--border);
}

.scholarship-detail-header h1 {
    margin: 0;
}

.detail-section {
    margin-bottom: var(--space-5);
    padding: var(--space-4);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.detail-section:last-child {
    border-bottom: 1px solid var(--border);
}

.detail-section h2 {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-bottom: var(--space-3);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 700;
}

.detail-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-3);
    margin: 0;
}

.detail-list dt {
    font-weight: 700;
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin-bottom: var(--space-1);
}

.detail-list dd {
    margin: 0 0 var(--space-3);
}

.detail-list dd:last-child {
    margin-bottom: 0;
}

/* Award emphasis + secondary annotations */
.award-highlight {
    font-size: var(--text-md);
    font-weight: 700;
    color: var(--brand-700);
}

.muted {
    color: var(--text-muted);
    font-size: var(--text-sm);
}

.detail-contact {
    overflow-wrap: anywhere;
}

.detail-caveat {
    padding: var(--space-3) var(--space-4);
    margin-bottom: var(--space-5);
    border: 1px solid #ffe69c;
    border-left: 4px solid var(--warning);
    border-radius: var(--radius);
    background: var(--warning-bg);
    color: var(--warning);
}

.award-cell {
    white-space: nowrap;
}

.award-monthly {
    font-weight: 700;
}

.award-unit {
    color: var(--text-muted);
    font-size: var(--text-xs);
}

.award-variable {
    color: var(--text-muted);
    font-style: italic;
}

.detail-actions {
    display: flex;
    gap: var(--space-3);
    margin-top: var(--space-5);
    padding-top: var(--space-4);
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

/* ------------------------------------------------------------------ */
/* Utilities                                                          */
/* ------------------------------------------------------------------ */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* ------------------------------------------------------------------ */
/* Media queries (mobile-first enhancements)                          */
/* ------------------------------------------------------------------ */

/* ---- Collapsible nav on small screens ----
   Default (no .js on <html>): toggle hidden, nav always visible (stacked).
   With .js: toggle shown, nav collapsed until opened. */
@media (max-width: 767.98px) {
    .header-inner {
        flex-wrap: nowrap;
        align-items: center;
    }

    .site-brand {
        flex: 1 1 auto;
    }

    .js .nav-toggle {
        display: inline-flex;
    }

    .js .site-header nav {
        flex: 1 0 100%;
        order: 3;
    }

    .js .site-header nav .nav-links {
        display: none;
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-1);
        padding: var(--space-2) 0;
    }

    .js .site-header nav .nav-links.is-open {
        display: flex;
    }

    .nav-links li {
        width: 100%;
    }

    .nav-links a,
    .nav-links button {
        width: 100%;
        justify-content: flex-start;
        padding: var(--space-3) var(--space-4);
    }

    .hero {
        padding: var(--space-6) var(--space-4);
    }

    .hero h1 {
        font-size: var(--text-xl);
    }

    /* The stacked-card table layout lives in the ≤1023.98px block below,
       which covers this width too. */

    .detail-actions,
    .action-buttons,
    .form-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .detail-actions .button,
    .detail-actions button,
    .action-buttons .button,
    .action-buttons button,
    .form-actions .button,
    .form-actions button {
        width: 100%;
    }

    .filter-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-actions button,
    .filter-actions .button {
        width: 100%;
    }
}

/* ---- ≥480px: small tablets ---- */
@media (min-width: 480px) {
    .hero-actions {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .hero-actions .button {
        width: auto;
    }

    .filter-actions {
        flex-direction: row;
        align-items: center;
    }

    .filter-actions button,
    .filter-actions .button {
        width: auto;
    }
}

/* ---- ≥768px: tablet / desktop ---- */
@media (min-width: 768px) {
    .container {
        padding: var(--space-6) var(--space-5);
    }

    .header-inner {
        padding: var(--space-4) var(--space-5);
    }

    .filter-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .checkbox-group {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
    }

    .detail-list {
        grid-template-columns: 12rem 1fr;
        gap: var(--space-2) var(--space-4);
    }

    .detail-list dt {
        text-align: right;
        margin-bottom: 0;
    }

    .detail-list dd {
        margin-bottom: var(--space-2);
    }

    .hero {
        padding: var(--space-8) var(--space-7);
    }

    .hero h1 {
        font-size: var(--text-3xl);
    }

    .hero p {
        font-size: var(--text-md);
    }
}

/* ---- 768px–1023px: too narrow for nine columns ---- */
/* The table needs about 60rem before its columns stop tearing words in half
   ("Kita-mishi"). Below that the stacked-card layout is used instead — the
   same rules the phone layout applies, kept in one place. */
@media (max-width: 1023.98px) {
    .table-wrapper {
        border: none;
        box-shadow: none;
        overflow: visible;
        background: none;
    }

    .scholarship-table thead {
        display: none;
    }

    .scholarship-table,
    .scholarship-table tbody {
        display: block;
        width: 100%;
    }

    .scholarship-table tr {
        display: block;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        box-shadow: var(--shadow-sm);
        margin-bottom: var(--space-4);
        padding: var(--space-3);
    }

    .scholarship-table td {
        display: block;
        border: none;
        padding: var(--space-2) 0;
        width: 100%;
    }

    .scholarship-table td::before {
        content: attr(data-label);
        display: block;
        font-weight: 700;
        font-size: var(--text-xs);
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: var(--text-muted);
        margin-bottom: var(--space-1);
    }
}

/* ---- ≥1024px: wide desktop ---- */
@media (min-width: 1024px) {
    .filter-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    /* Fixed widths, so a long foundation name cannot squeeze the award and
       period columns down to one word per line. */
    .scholarship-table {
        table-layout: fixed;
    }

    .scholarship-table th:nth-child(1) { width: 12%; }  /* Type      */
    .scholarship-table th:nth-child(2) { width: 13%; }  /* Foundation*/
    .scholarship-table th:nth-child(3) { width: 17%; }  /* Name      */
    .scholarship-table th:nth-child(4) { width: 11%; }  /* Level     */
    .scholarship-table th:nth-child(5) { width: 7%; }   /* Countries */
    .scholarship-table th:nth-child(6) { width: 11%; }  /* Schools   */
    .scholarship-table th:nth-child(7) { width: 9%; }   /* Fields    */
    .scholarship-table th:nth-child(8) { width: 9%; }   /* Award     */
    .scholarship-table th:nth-child(9) { width: 11%; }  /* Period    */
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
    }

    .text-clamp {
        transition: none;
    }
}

/* ---- Print ---- */
@media print {
    .site-header,
    .skip-link,
    .site-footer,
    .nav-toggle,
    .filter-toggle,
    #filter-panel {
        display: none !important;
    }

    body {
        font-size: 11pt;
        color: #000;
        background: #fff;
    }

    a {
        text-decoration: underline;
    }

    .detail-section {
        box-shadow: none;
        border-color: #999;
    }

    .filter-actions,
    .detail-actions {
        display: none;
    }
}

/* ---------- Pagination ---------- */
.pagination {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
    margin: var(--space-4) 0;
    padding: var(--space-3) 0;
}

.pagination-link {
    display: inline-flex;
    align-items: center;
    padding: var(--space-2) var(--space-3);
    min-height: 36px;
    font-size: var(--text-sm);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    transition: background-color 0.15s ease;
}

.pagination-link:hover {
    background: var(--surface-muted);
}

.pagination-link:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.pagination-current {
    color: var(--text-muted);
    font-size: var(--text-sm);
}
