/**
 * @file styles.css
 * @description Estilos del portfolio de Martín Pentito.
 *   Implementa una estética de editor de código (VSCode-like) con soporte para
 *   3 temas intercambiables vía variables CSS, diseño responsive para todos los
 *   breakpoints modernos (320px – 4K), animaciones de entrada y accesibilidad.
 * @author Martín Pentito
 */

/* ─── Reset global ─────────────────────────────────────────────────────────────── */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ─── Variables CSS (tema Dark+ por defecto) ───────────────────────────────────
   Los temas alternativos (Monokai, Abyss) sobreescriben estas variables
   mediante JavaScript (script.js → applyTheme). */
:root {
    color-scheme: dark;
    --bg-main: #1e1e1e;
    --bg-panel: #252526;
    --bg-card: #2d2d30;
    --border: #3e3e42;
    --text-main: #d4d4d4;
    --text-muted: #858585;
    --accent: #4ade80;
    --accent-strong: #86efac;
    --comment: #6a9955;
    --keyword: #569cd6;
    --string: #ce9178;
    --number: #b5cea8;
    --function: #dcdcaa;
    --accent-rgb: 74, 222, 128;
    --accent-strong-rgb: 134, 239, 172;
    --keyword-rgb: 86, 156, 214;
    --statusbar-bg: #166534;
    --statusbar-text: #ffffff;
    --sidebar-width: clamp(240px, 24vw, 320px);
    --content-font-size: clamp(12px, 0.35vw + 11px, 15px);
}

/* ─── Skip link (accesibilidad) ─── */
.skip-link {
    position: absolute;
    top: -100%;
    left: 8px;
    z-index: 9999;
    padding: 8px 16px;
    background-color: var(--accent);
    color: var(--bg-main);
    font-weight: bold;
    font-family: inherit;
    font-size: 13px;
    border-radius: 0 0 6px 6px;
    text-decoration: none;
    transition: top 0.12s ease;
}

.skip-link:focus {
    top: 0;
}

/* ─── Focus visible global ─── */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 2px;
}

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

/* ─── Layout principal ────────────────────────────────────────────────────────────
   flex row en desktop, flex column en mobile (≤768px).
   .sidebar: panel lateral fijo | .main-wrapper: zona de contenido principal */
body {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    background: radial-gradient(circle at top, #252526 0%, var(--bg-main) 55%);
    color: var(--text-main);
    min-height: 100vh;
    transition: background-color 0.25s ease, color 0.25s ease;
}

.container {
    display: flex;
    width: 100%;
    height: 100vh;    /* fallback */
    height: 100dvh;   /* excluye chrome del browser en mobile */
}

.sidebar {
    flex: 0 0 var(--sidebar-width);
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border);
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ─── Sidebar: imagen de perfil ──────────────────────────────────────────────────────
   Muestra foto de perfil circular. Si la imagen falla, .profile-fallback
   muestra las iniciales del nombre (JavaScript añade la clase `missing-image`). */
.profile-frame {
    position: relative;
    width: 160px;
    height: 160px;
    margin-bottom: 20px;
}

.profile-img,
.profile-fallback {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid var(--accent);
}

.profile-img {
    object-fit: contain;
    display: block;
    background-color: transparent;
}

.profile-fallback {
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 42px;
    font-weight: bold;
    color: var(--accent-strong);
    background: linear-gradient(135deg, #1f1f22 0%, #303036 100%);
}

.profile-frame.missing-image .profile-img {
    display: none;
}

.profile-frame.missing-image .profile-fallback {
    display: flex;
}

.tag {
    color: var(--string);
    font-size: 14px;
    margin-bottom: 20px;
}

#sidebar-content {
    width: 100%;
}

.sidebar-name {
    color: var(--accent);
    font-size: 14px;
    font-weight: bold;
    text-align: center;
    margin-bottom: 4px;
}

.sidebar-title {
    color: var(--text-muted);
    font-size: 11px;
    text-align: center;
    line-height: 1.6;
    margin-bottom: 20px;
    min-height: 1.6em;
}

.section {
    width: 100%;
    margin-bottom: 20px;
    text-align: left;
}

.section-title {
    color: var(--accent);
    font-weight: bold;
    margin-bottom: 8px;
    font-size: 13px;
}

.enum-content {
    font-size: 12px;
    line-height: 1.7;
    color: var(--text-main);
    margin-left: 10px;
}

.enum-item {
    color: var(--text-main);
    word-break: break-word;
}

.enum-item a {
    color: var(--accent-strong);
    text-decoration: none;
}

.enum-item a:hover {
    text-decoration: underline;
}

.media-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid transparent;
    transition: background-color 0.15s, border-color 0.15s, transform 0.15s;
    text-decoration: none !important;
}

.media-link:hover {
    background-color: rgba(var(--accent-strong-rgb), 0.08);
    border-color: rgba(var(--accent-strong-rgb), 0.30);
    transform: translateX(3px);
    text-decoration: none !important;
}

.media-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    transition: transform 0.15s;
}

.media-link:hover .media-icon {
    transform: scale(1.15);
}

/* ─── Wrapper principal y tabs de navegación ──────────────────────────────────────
   Ocupa el espacio restante al sidebar. Contiene la tab-bar, el main-content
   y el statusbar. La tab-bar es scrollable horizontalmente en pantallas pequeñas. */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.tab-bar {
    display: flex;
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    flex-shrink: 0;
}

.sidebar-toggle {
    display: none;
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    background-color: var(--bg-card);
    color: var(--text-main);
    font: inherit;
    font-size: 12px;
    line-height: 1;
    padding: 10px 12px;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s;
}

.sidebar-toggle:hover {
    border-color: var(--accent);
    background-color: rgba(var(--accent-rgb), 0.10);
}

.tab-bar::-webkit-scrollbar {
    height: 3px;
}

.nav-tab {
    color: var(--text-muted);
    text-decoration: none;
    padding: 10px 20px;
    font-size: 13px;
    font-family: inherit;
    white-space: nowrap;
    border-top: 2px solid transparent;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, background-color 0.15s;
}

.nav-tab:hover {
    color: var(--text-main);
    background-color: rgba(255, 255, 255, 0.04);
}

.nav-tab.active {
    color: var(--text-main);
    border-top-color: var(--accent);
    background-color: var(--bg-main);
}

.theme-switcher {
    width: 100%;
    margin-top: 12px;
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

.theme-switcher-title,
.lang-switcher-title {
    color: var(--accent);
    font-weight: bold;
    margin-bottom: 8px;
    font-size: 13px;
}

.theme-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.theme-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 7px;
    min-height: 36px;
    padding: 7px;
    font: inherit;
    color: var(--text-main);
    background-color: var(--bg-card);
    cursor: pointer;
    transition: border-color 0.15s, transform 0.15s, background-color 0.15s;
}

.theme-btn:hover {
    border-color: var(--accent);
    background-color: rgba(var(--accent-rgb), 0.12);
}

.theme-btn.active {
    border-color: var(--accent);
    background-color: rgba(var(--accent-rgb), 0.16);
    box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), 0.28);
}

.theme-btn:focus-visible {
    outline: 2px solid rgba(var(--accent-rgb), 0.6);
    outline-offset: 1px;
}

.lang-switcher {
    width: 100%;
    margin-top: 10px;
}

.lang-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.lang-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 7px;
    min-height: 32px;
    padding: 6px;
    font: inherit;
    font-size: 10px;
    letter-spacing: 0.06em;
    color: var(--text-main);
    background-color: var(--bg-card);
    cursor: pointer;
    transition: border-color 0.15s, transform 0.15s, background-color 0.15s;
}

.lang-btn:hover {
    border-color: var(--accent);
    background-color: rgba(var(--accent-rgb), 0.12);
}

.lang-btn.active {
    border-color: var(--accent);
    background-color: rgba(var(--accent-rgb), 0.16);
    box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), 0.28);
}

.lang-btn:focus-visible {
    outline: 2px solid rgba(var(--accent-rgb), 0.6);
    outline-offset: 1px;
}

.theme-icon {
    font-size: 1.1rem;
    line-height: 1;
}

.theme-icon-dark {
    color: #4fc1ff;
}

.theme-icon-monokai {
    color: #a6e22e;
}

.theme-icon-abyss {
    color: #48c6ff;
}

/* ─── Área de contenido principal ─────────────────────────────────────────────────────
   Zona con scroll que contiene todas las secciones `.code-section`.
   Líneas de código: número (.line-number) + contenido (.code).
   Tokens de sintaxis: .keyword, .string, .comment, .function, etc. */
.main-content {
    flex: 1;
    padding: clamp(10px, 2vw, 24px) clamp(12px, 3vw, 40px) clamp(96px, 24vh, 260px);
    overflow-y: auto;
    font-size: var(--content-font-size);
    line-height: 1.55;
}

#main-content {
    width: min(100%, 1500px);
    margin: 0 auto;
}

.status {
    color: var(--text-muted);
}

.code-section {
    padding-bottom: 48px;
}

/* ─── Animación de entrada al hacer scroll ─── */
.code-section.animate-in {
    transform: translateY(18px);
    transition: transform 0.45s ease;
}

.code-section.animate-in.visible {
    transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
    .code-section.animate-in {
        transform: none;
        transition: none;
    }
}

.code-section + .code-section {
    border-top: 1px solid var(--border);
    padding-top: 16px;
}

.code-line {
    display: flex;
    align-items: flex-start;
    margin-bottom: 2px;
    padding: 0 6px;
    border-radius: 2px;
    transition: background-color 0.12s;
}

.code-line:hover {
    background-color: rgba(255, 255, 255, 0.04);
}

.line-number {
    color: var(--text-muted);
    margin-right: 15px;
    min-width: 40px;
    text-align: right;
    user-select: none;
}

.code {
    flex: 1;
    min-width: 0;
    overflow-wrap: break-word;
    word-break: break-word;
}

.comment {
    color: var(--comment);
}

.keyword {
    color: var(--keyword);
}

.class-name {
    color: var(--accent);
}

.string {
    color: var(--string);
}

.property {
    color: var(--text-main);
}

.value {
    color: var(--string);
}

.type {
    color: var(--keyword);
}

.number {
    color: var(--number);
}

.bracket {
    color: var(--text-main);
}

.operator {
    color: var(--text-main);
}

.function {
    color: var(--function);
}

.copyable {
    cursor: pointer;
}

.copyable:hover {
    text-decoration: underline;
}

.inline-mailto {
    font-size: 11px;
    opacity: 0.55;
    color: var(--accent);
    text-decoration: none;
    margin-left: 4px;
    vertical-align: middle;
    transition: opacity 0.15s;
}

.inline-mailto:hover {
    opacity: 1;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0; }
}

.cursor {
    display: inline-block;
    color: var(--accent-strong);
    animation: blink 1s step-end infinite;
    margin-left: 2px;
}

.boot-line {
    color: var(--text-muted);
    line-height: 1.9;
}

.boot-line.done {
    color: var(--accent);
}

/* ─── Skill Icon Grid ─── */
.skill-grid-line {
    align-items: flex-start;
    padding: 4px 6px;
}

.skill-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 0 10px 32px;
}

.skill-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background-color: var(--bg-card);
    min-width: 64px;
    flex: 1 1 90px;
    transition: border-color 0.15s, transform 0.15s, background-color 0.15s;
    cursor: default;
}

.skill-badge:hover {
    border-color: var(--accent);
    background-color: rgba(var(--accent-rgb), 0.06);
    transform: translateY(-2px);
}

.skill-icon {
    font-size: 2rem;
    color: var(--accent);
    line-height: 1;
}

.skill-label {
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ─── Stats Grid ─── */
.stat-grid-line {
    align-items: flex-start;
    padding: 4px 6px;
}

.stat-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 12px 0 12px 32px;
}

.stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 18px 28px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background-color: var(--bg-card);
    min-width: 120px;
    flex: 1 1 140px;
    transition: border-color 0.15s, transform 0.15s, background-color 0.15s;
    cursor: default;
}

.stat-card:hover {
    border-color: var(--accent);
    background-color: rgba(var(--accent-rgb), 0.06);
    transform: translateY(-3px);
}

.stat-icon {
    font-size: 2rem;
    color: var(--accent);
    line-height: 1;
}

.stat-number {
    font-size: 2.2rem;
    font-weight: bold;
    color: var(--accent-strong);
    line-height: 1;
}

.stat-label {
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ─── Entry Cards (Experience, Education, Services, Projects) ─── */
.card-grid-line {
    align-items: flex-start;
    padding: 4px 6px;
}

.card-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px 0 10px 32px;
    width: 100%;
}

.entry-card {
    padding: 14px 18px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background-color: var(--bg-card);
    transition: border-color 0.15s, transform 0.15s, background-color 0.15s;
    cursor: default;
}

.entry-card:hover {
    border-color: var(--accent);
    background-color: rgba(var(--accent-rgb), 0.06);
    transform: translateX(3px);
}

.entry-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}

.entry-title {
    color: var(--function);
    font-weight: bold;
    font-size: 13px;
}

.entry-period {
    color: var(--number);
    font-size: 11px;
    white-space: nowrap;
    flex-shrink: 0;
}

.entry-meta {
    color: var(--text-muted);
    font-size: 11px;
    margin-bottom: 6px;
}

.entry-context {
    color: var(--number);
    font-size: 11px;
    margin-bottom: 6px;
}

.entry-desc {
    color: var(--string);
    font-size: 12px;
    line-height: 1.6;
}

.case-study {
    margin-top: 8px;
    padding: 8px 10px;
    border: 1px dashed var(--border);
    border-radius: 6px;
    background-color: rgba(var(--accent-rgb), 0.04);
}

.case-study-row {
    display: flex;
    gap: 8px;
    font-size: 11px;
    line-height: 1.6;
}

.case-study-row + .case-study-row {
    margin-top: 3px;
}

.case-study-label {
    color: var(--keyword);
    font-weight: bold;
    min-width: 64px;
    flex-shrink: 0;
}

.case-study-text {
    color: var(--text-main);
}

.entry-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.entry-tag {
    font-size: 10px;
    padding: 2px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--keyword);
    background-color: rgba(var(--keyword-rgb), 0.08);
}

.entry-links {
    display: flex;
    gap: 10px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.entry-link {
    font-size: 11px;
    color: var(--accent-strong);
    text-decoration: none;
    padding: 3px 10px;
    border: 1px solid rgba(var(--accent-strong-rgb), 0.3);
    border-radius: 4px;
    transition: background-color 0.15s, border-color 0.15s;
}

.entry-link:hover {
    background-color: rgba(var(--accent-rgb), 0.1);
    border-color: var(--accent);
    text-decoration: none;
}

.project-controls-line {
    align-items: flex-start;
    padding: 6px;
}

.project-controls {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr auto;
    gap: 8px;
    align-items: center;
    padding: 10px 0 8px 32px;
}

.project-search,
.project-select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 6px;
    background-color: var(--bg-card);
    color: var(--text-main);
    font: inherit;
    font-size: 11px;
    padding: 7px 10px;
}

.project-search:focus,
.project-select:focus {
    outline: 2px solid rgba(var(--accent-rgb), 0.45);
    outline-offset: 1px;
}

.project-results {
    color: var(--text-muted);
    font-size: 11px;
    justify-self: end;
    white-space: nowrap;
}

.project-filter-empty {
    color: var(--text-muted);
}

.command-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(2px);
    z-index: 80;
}

@keyframes paletteIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-6px) scale(0.97); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0)    scale(1);    }
}

@keyframes paletteOut {
    from { opacity: 1; transform: translateX(-50%) translateY(0)    scale(1);    }
    to   { opacity: 0; transform: translateX(-50%) translateY(-6px) scale(0.97); }
}

.command-palette {
    position: fixed;
    top: 14vh;
    left: 50%;
    transform: translateX(-50%);
    width: min(680px, calc(100vw - 28px));
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.35);
    z-index: 90;
    overflow: hidden;
    animation: paletteIn 0.14s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.command-palette.closing {
    animation: paletteOut 0.11s ease-in forwards;
}

.command-header {
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid var(--border);
    padding: 10px 12px;
}

.command-header-icon {
    color: var(--accent);
    font-size: 1rem;
}

.command-input {
    flex: 1;
    border: 0;
    background: transparent;
    color: var(--text-main);
    font: inherit;
    font-size: 13px;
    outline: 0;
}

.command-list {
    list-style: none;
    max-height: 46vh;
    overflow-y: auto;
}

.command-item,
.command-empty {
    padding: 10px 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.03);
    font-size: 12px;
}

.command-item {
    cursor: pointer;
    color: var(--text-main);
}

.command-item:hover,
.command-item.active {
    background-color: rgba(var(--accent-rgb), 0.12);
}

.command-empty {
    color: var(--text-muted);
}

/* ─── Typing animation in sidebar ─── */
.sidebar-title {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: nowrap;
    gap: 1px;
}

.typing-cursor {
    display: inline-block;
    color: var(--accent);
    animation: blink 1s step-end infinite;
    font-weight: 100;
    line-height: 1;
    flex-shrink: 0;
}

/* ─── Statusbar inferior ──────────────────────────────────────────────────────────────
   Barra inferior fija de 22 px estilo VSCode. Muestra lenguaje, encoding,
   líneas totales, sección activa y atajo del command palette.
   Inicializada dinámicamente por initStatusBar() en script.js. */
.statusbar {
    height: 22px;
    background-color: var(--statusbar-bg);
    color: var(--statusbar-text);
    font-size: 12px;
    font-family: inherit;
    display: flex;
    align-items: stretch;
    flex-shrink: 0;
    user-select: none;
    overflow: hidden;
}

.statusbar-left,
.statusbar-right {
    display: flex;
    align-items: center;
}

.statusbar-right {
    margin-left: auto;
}

.statusbar-item {
    padding: 0 10px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    cursor: default;
    transition: background-color 0.1s;
}

.statusbar-item:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

.statusbar-item.command-hint {
    cursor: pointer;
    gap: 4px;
    letter-spacing: 0.02em;
}

.statusbar-item.command-hint kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 3px;
    font: inherit;
    font-size: 10px;
    line-height: 14px;
    background-color: rgba(255, 255, 255, 0.08);
}

.toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background-color: var(--bg-card);
    color: var(--text-main);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
}

.toast.visible {
    opacity: 1;
    transform: translateY(0);
}

::-webkit-scrollbar {
    width: 12px;
}

::-webkit-scrollbar-track {
    background: var(--bg-main);
}

::-webkit-scrollbar-thumb {
    background: #464647;
    border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
    background: #5a5a5a;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-12px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ═══════════════════════════════════════════════
   RESPONSIVE — Breakpoints 2025/2026
   Dispositivos cubiertos:
     - Smartwatches / plegables exteriores  ≤ 320px
     - Teléfonos pequeños (iPhone SE)       ≤ 390px
     - Teléfonos estándar                   ≤ 480px
     - Teléfonos grandes / tablets pequeñas ≤ 600px
     - Tablets portrait / iPad              ≤ 768px
     - Tablets landscape / laptops          ≤ 1024px
     - Laptops / monitores estándar         ≤ 1280px
     - QHD / MacBook Pro                    ≥ 1440px
     - Full HD / 4K                         ≥ 1920px
   + Landscape móvil, touch, reduced-motion,
     forced-colors (accesibilidad), print
   ═══════════════════════════════════════════════ */

/* ─── QHD / Ultrawide  (≥ 1440px) ─── */
@media (min-width: 1440px) {
    .container {
        max-width: 1800px;
        margin: 0 auto;
    }

    .sidebar {
        flex-basis: 320px;
    }

    .main-content {
        padding: 24px 44px;
        font-size: 14px;
    }
}

/* ─── Full HD / 4K  (≥ 1920px) ─── */
@media (min-width: 1920px) {
    .container {
        max-width: 2200px;
    }

    .main-content {
        font-size: 15px;
        padding: 30px 60px;
    }
}

/* ─── Laptop / small desktop  (≤ 1280px) ─── */
@media (max-width: 1280px) {
    .sidebar {
        flex-basis: 260px;
        padding: 18px;
    }
}

/* ─── Small desktop / large tablet  (≤ 900px) ─── */
@media (max-width: 900px) {
    .project-controls {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .project-search {
        grid-column: 1 / -1;
    }

    .project-results {
        justify-self: start;
    }

    .entry-header {
        align-items: flex-start;
    }

    .case-study-row {
        flex-direction: column;
        gap: 2px;
    }

    .case-study-label {
        min-width: 0;
    }
}

/* ─── Tablet landscape / small laptop  (≤ 1024px) ─── */
@media (max-width: 1024px) {
    .sidebar {
        flex-basis: 220px;
        padding: 16px;
    }

    .main-content {
        padding: 18px 20px;
    }

    .nav-tab {
        padding: 10px 14px;
    }
}

/* ─── Tablet portrait / iPad  (≤ 768px) ─── */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }

    .main-wrapper {
        order: 1;
        flex: 1 1 auto;
        min-height: 68vh;
    }

    .sidebar-toggle {
        display: block;
    }

    /* Sidebar moves below content as a secondary panel */
    .sidebar {
        order: 2;
        flex: none;
        width: 100%;
        max-height: 32vh;
        border-right: none;
        border-top: 1px solid var(--border);
        border-bottom: none;
        padding: 12px 16px;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: flex-start;
        align-content: flex-start;
        gap: 10px;
        transition: max-height 0.22s ease, padding 0.22s ease, border-color 0.22s ease, opacity 0.18s ease;
        opacity: 1;
    }

    body.mobile-sidebar-collapsed .sidebar {
        max-height: 0;
        padding-top: 0;
        padding-bottom: 0;
        border-top-color: transparent;
        opacity: 0;
        overflow: hidden;
    }

    .tag {
        display: none;
    }

    .profile-frame {
        width: 80px;
        height: 80px;
        margin-bottom: 0;
    }

    .profile-fallback {
        font-size: 26px;
    }

    #sidebar-content {
        flex: 1;
        min-width: 180px;
    }

    .theme-switcher {
        width: 100%;
        margin-top: 2px;
        border-top: 0;
        padding-top: 0;
    }

    .lang-switcher {
        width: 100%;
    }

    .sidebar-name {
        text-align: left;
    }

    .sidebar-title {
        text-align: left;
        margin-bottom: 8px;
    }

    .nav-tab {
        padding: 9px 12px;
        font-size: 12px;
    }

    .tab-bar {
        position: sticky;
        top: 0;
        z-index: 4;
        background-color: var(--bg-card);
    }

    .main-content {
        padding: 11px 13px;
    }

    .line-number {
        min-width: 28px;
        margin-right: 10px;
    }

    .card-grid {
        padding: 8px 0 8px 16px;
    }

    .project-controls {
        grid-template-columns: 1fr;
        padding-left: 16px;
    }

    .project-results {
        justify-self: start;
    }

    .command-palette {
        top: 10vh;
    }

    .entry-card {
        padding: 12px 14px;
    }
}

/* ─── Small tablet / large phone  (≤ 600px) ─── */
@media (max-width: 600px) {
    .sidebar {
        max-height: 30vh;
        padding: 10px 12px;
        gap: 8px;
    }

    .profile-frame {
        width: 64px;
        height: 64px;
    }

    .profile-fallback {
        font-size: 20px;
    }

    #sidebar-content {
        min-width: 150px;
    }

    .theme-buttons {
        grid-template-columns: 1fr;
    }

    .lang-buttons {
        grid-template-columns: repeat(2, 1fr);
    }

    .nav-tab {
        padding: 8px 10px;
        font-size: 11px;
    }

    .main-content {
        padding: 10px 12px;
    }

    .line-number {
        min-width: 22px;
        margin-right: 8px;
        font-size: 11px;
    }

    .statusbar-item {
        padding: 0 7px;
        font-size: 11px;
    }

    .card-grid {
        padding: 6px 0 6px 10px;
        gap: 8px;
    }

    .project-controls {
        padding-left: 10px;
    }

    .command-palette {
        width: calc(100vw - 16px);
    }

    .entry-card {
        padding: 10px 12px;
    }

    .entry-title {
        font-size: 12px;
    }
}

/* ─── Teléfonos estándar  (≤ 480px) ─── */
@media (max-width: 480px) {
    .sidebar {
        max-height: 27vh;
        padding: 9px 10px;
        gap: 7px;
    }

    .profile-frame {
        width: 54px;
        height: 54px;
    }

    .profile-fallback {
        font-size: 16px;
    }

    #sidebar-content {
        min-width: 130px;
    }

    .sidebar-name {
        font-size: 13px;
    }

    .nav-tab {
        padding: 8px 9px;
        font-size: 11px;
    }

    .main-content {
        padding: 10px 10px;
    }

    .line-number {
        min-width: 18px;
        margin-right: 6px;
    }

    .toast {
        right: 10px;
        left: 10px;
        bottom: 30px;
    }

    .statusbar {
        font-size: 11px;
    }

    .statusbar-item {
        padding: 0 6px;
    }
}

/* ─── Teléfonos pequeños — iPhone SE, Galaxy A  (≤ 390px) ─── */
@media (max-width: 390px) {
    .sidebar {
        max-height: 24vh;
        flex-direction: row;
        align-items: flex-start;
        padding: 8px 10px;
        gap: 6px;
    }

    .profile-frame {
        width: 52px;
        height: 52px;
    }

    #sidebar-content {
        width: 100%;
        min-width: unset;
    }

    .theme-switcher {
        width: 100%;
    }

    .sidebar-name {
        text-align: left;
        font-size: 12px;
    }

    .sidebar-title {
        text-align: left;
        font-size: 10px;
        margin-bottom: 4px;
    }

    /* Números de línea: ocultar para ganar espacio */
    .line-number {
        display: none;
    }

    .nav-tab {
        padding: 7px 8px;
        font-size: 10px;
    }

    .main-content {
        padding: 8px;
    }

    .entry-links {
        flex-direction: column;
        align-items: stretch;
    }

    .entry-link {
        text-align: center;
    }

    .statusbar-item {
        padding: 0 5px;
        font-size: 10px;
    }

    .project-controls {
        padding-left: 0;
    }
}

/* ─── Mínimo absoluto — iPhone SE 1ª gen, smartwatches  (≤ 320px) ─── */
@media (max-width: 320px) {
    .nav-tab {
        padding: 6px 7px;
        font-size: 10px;
    }

    .main-content {
        padding: 6px 8px;
    }
}

/* ─── Landscape en teléfonos  (altura ≤ 500px, ancho ≤ 900px) ─── */
@media (max-height: 500px) and (orientation: landscape) and (max-width: 900px) {
    .container {
        flex-direction: row !important;
    }

    .sidebar {
        flex: 0 0 170px !important;
        width: 170px !important;
        border-right: 1px solid var(--border) !important;
        border-bottom: none !important;
        flex-direction: column !important;
        align-items: center !important;
        padding: 8px !important;
        overflow-y: auto;
        max-height: 100vh;
        gap: 4px !important;
    }

    .profile-frame {
        width: 50px !important;
        height: 50px !important;
        margin-bottom: 0 !important;
    }

    #sidebar-content {
        width: 100% !important;
        min-width: unset !important;
    }

    .sidebar-name {
        font-size: 11px !important;
        text-align: center !important;
    }

    .sidebar-title {
        font-size: 9px !important;
        text-align: center !important;
        margin-bottom: 4px !important;
    }

    .line-number {
        display: none !important;
    }

    .main-content {
        padding: 6px 10px !important;
        font-size: 11px !important;
    }
}

/* ─── Touch (sin hover / pointer grueso) ─── */
@media (hover: none) and (pointer: coarse) {
    /* Eliminar efectos hover que no funcionan en touch */
    .code-line:hover {
        background-color: transparent;
    }

    .nav-tab:hover {
        background-color: transparent;
        color: var(--text-muted);
    }

    .nav-tab.active,
    .nav-tab.active:hover {
        color: var(--text-main);
        background-color: var(--bg-main);
    }

    .media-link:hover {
        background-color: transparent;
        border-color: transparent;
        transform: none;
    }

    .media-link:hover .media-icon {
        transform: none;
    }

    .statusbar-item:hover {
        background-color: transparent;
    }

    /* Tap targets mínimos 44px (WCAG 2.5.5) */
    .nav-tab {
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    .media-link {
        padding: 10px 8px;
        min-height: 44px;
    }
}

/* ─── Reduced motion (accesibilidad) ─── */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .cursor {
        animation: none;
        opacity: 1;
    }
}

/* ─── Alto contraste forzado (Windows Contrast Themes) ─── */
@media (forced-colors: active) {
    .nav-tab.active {
        border-top-color: Highlight;
    }

    .profile-img,
    .profile-fallback {
        border-color: ButtonBorder;
    }

    .statusbar {
        background-color: Highlight;
        color: HighlightText;
        forced-color-adjust: none;
    }

    .code-line:hover {
        background-color: Highlight;
        color: HighlightText;
        forced-color-adjust: none;
    }
}

/* ─── Impresión ─── */
@media print {
    body {
        background: #fff !important;
        color: #000 !important;
    }

    .container {
        flex-direction: column !important;
        min-height: unset;
    }

    .sidebar {
        flex: none !important;
        width: 100% !important;
        border: none !important;
        border-bottom: 1px solid #ccc !important;
        background: #f8f8f8 !important;
        color: #000 !important;
        flex-direction: row;
        align-items: center;
        gap: 16px;
        padding: 12px;
    }

    .tag {
        display: none;
    }

    .tab-bar,
    .statusbar {
        display: none !important;
    }

    .main-wrapper {
        overflow: visible !important;
    }

    .main-content {
        overflow: visible !important;
        font-size: 10pt;
        color: #000 !important;
        padding: 16px 0;
    }

    .code-section {
        page-break-inside: avoid;
    }

    .keyword, .class-name, .function, .accent {
        color: #000 !important;
    }

    .comment {
        color: #555 !important;
    }

    .string, .value {
        color: #333 !important;
    }

    a {
        color: #000 !important;
        text-decoration: none;
    }

    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 8pt;
        color: #555;
    }
}
