/* --------------------------------------------------------------------------
   1. Custom Properties (Design Tokens)
   -------------------------------------------------------------------------- */

:root {
  /* Colors — Light Theme (Default) */
  --color-bg: #f8fafc;
  --color-text: #1e293b;
  --color-text-muted: #475569;
  --color-link: #2563eb;
  --color-link-hover: #1d4ed8;
  --color-border: #cbd5e1;
  --color-specs-bg: #ffffff;
  --color-specs-border: #94a3b8;
  --color-specs-note: #15803d;
  --color-modal-header-bg: #1e293b;
  --color-modal-header-text: #f8fafc;

  /* Layout */
  --content-max-width: 720px;
  --content-padding: 1.5rem;

  /* Typography */
  --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'Courier New', Courier, monospace;
  --font-size-base: 1rem;
  --line-height-base: 1.7;
}

[data-theme="dark"] {
  /* Colors — Dark Theme */
  --color-bg: #0f172a;
  --color-text: #f1f5f9;
  --color-text-muted: #94a3b8;
  --color-link: #60a5fa;
  --color-link-hover: #93c5fd;
  --color-border: #334155;
  --color-specs-bg: #1e293b;
  --color-specs-border: #475569;
  --color-specs-note: #4ade80;
  --color-modal-header-bg: #020617;
  --color-modal-header-text: #f8fafc;
}


/* --------------------------------------------------------------------------
   2. Reset & Base
   -------------------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  color: var(--color-text);
  background-color: var(--color-bg);
  transition: background-color 0.2s ease, color 0.2s ease;
}


/* --------------------------------------------------------------------------
   3. Skip Link (Accessibility)
   -------------------------------------------------------------------------- */

.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  padding: 0.5rem 1rem;
  background: var(--color-link);
  color: #fff;
  font-weight: 700;
  border-radius: 0 0 4px 4px;
  z-index: 100;
  text-decoration: none;
}

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


/* --------------------------------------------------------------------------
   4. Header
   -------------------------------------------------------------------------- */

.site-header {
  background-color: var(--color-bg);
  color: var(--color-text);
  padding: 2rem var(--content-padding) 0;
}

.header-inner {
  max-width: var(--content-max-width);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 0.75rem 2rem;
  align-items: start;
}

.header-identity {
  grid-column: 1;
  grid-row: 1;
}

.site-title {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--color-text);
}

.site-subtitle {
  font-size: 0.95rem;
  color: var(--color-text-muted);
  margin-top: 0.2rem;
}

.site-nav {
  grid-column: 1;
  grid-row: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.25rem;
  margin-top: 0.25rem;
}

.site-nav a {
  color: var(--color-link);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-size: 0.95rem;
  font-weight: 500;
  transition: color 0.15s;
}

.site-nav a:hover,
.site-nav a:focus-visible {
  color: var(--color-link-hover);
}

.nav-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.lang-btn-content {
  display: inline-flex;
  align-items: center;
}

.flag-icon {
  width: 1.15em;
  height: 0.85em;
  display: inline-block;
  vertical-align: -0.1em;
  border-radius: 1.5px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18);
  margin: 0 0.35rem 0 0.15rem;
  flex-shrink: 0;
}

[data-theme="dark"] .flag-icon {
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--color-specs-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  cursor: pointer;
  line-height: 1.4;
  user-select: none;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  border-color: var(--color-link);
  color: var(--color-link);
  outline: 2px solid var(--color-link);
  outline-offset: 1px;
}

.header-divider {
  max-width: var(--content-max-width);
  margin: 1.5rem auto 0;
  border: none;
  border-top: 1px solid var(--color-border);
}


/* --------------------------------------------------------------------------
   5. System Specs Widget
   -------------------------------------------------------------------------- */

.system-specs {
  grid-column: 2;
  grid-row: 1 / 3;
  align-self: start;

  background: var(--color-specs-bg);
  color: var(--color-text);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.5;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--color-specs-border);
  border-radius: 4px;
  min-width: 170px;
}

.system-specs strong {
  display: block;
  font-size: 0.78rem;
  margin-bottom: 0.35rem;
  letter-spacing: 0.03em;
  color: var(--color-text);
}

.system-specs ul {
  list-style: none;
}

.system-specs li {
  white-space: nowrap;
}

.specs-note {
  margin-top: 0.35rem;
  color: var(--color-specs-note);
  font-size: 0.68rem;
  font-weight: 600;
}

.audit-btn {
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  font-size: inherit;
  color: var(--color-link);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  display: inline;
}

.audit-btn:hover,
.audit-btn:focus-visible {
  color: var(--color-link-hover);
}

.audit-btn span {
  font-size: 0.65rem;
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   5b. Audit Report Modal (Native <dialog>)
   -------------------------------------------------------------------------- */

.audit-dialog {
  width: 90vw;
  max-width: 1100px;
  height: 85vh;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.25), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
  padding: 0;
  margin: auto;
  overflow: hidden;
  background-color: var(--color-specs-bg);
  color: var(--color-text);
}

.audit-dialog::backdrop {
  background-color: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(2px);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background-color: var(--color-modal-header-bg);
  color: var(--color-modal-header-text);
  border-bottom: 1px solid var(--color-border);
}

.dialog-header h2 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  color: var(--color-header-text);
}

.dialog-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.dialog-ext-link {
  color: #93c5fd;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-decoration: underline;
}

.dialog-ext-link:hover {
  color: #bfdbfe;
}

.dialog-close-btn {
  background: none;
  border: none;
  color: var(--color-header-text);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}

.dialog-close-btn:hover,
.dialog-close-btn:focus-visible {
  background-color: rgba(255, 255, 255, 0.15);
}

.dialog-body {
  width: 100%;
  height: calc(85vh - 52px);
}

.dialog-body iframe {
  width: 100%;
  height: 100%;
  border: none;
}


/* --------------------------------------------------------------------------
   6. Main Content
   -------------------------------------------------------------------------- */

.content {
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: 2rem var(--content-padding) 3rem;
}

.content section {
  content-visibility: auto;
  contain-intrinsic-size: auto 300px;
}

.content h2 {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  letter-spacing: -0.01em;
}

.content h3 {
  font-size: 1.05rem;
  font-weight: 600;
}

.content p {
  margin-bottom: 0.75rem;
}

.content hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 2rem 0;
}


/* --------------------------------------------------------------------------
   7. Links
   -------------------------------------------------------------------------- */

a {
  color: var(--color-link);
  text-decoration: underline;
  text-underline-offset: 2px;
}

a:hover,
a:focus-visible {
  color: var(--color-link-hover);
}

a:focus-visible {
  outline: 2px solid var(--color-link);
  outline-offset: 2px;
  border-radius: 2px;
}


/* --------------------------------------------------------------------------
   8. Experience & Timeline
   -------------------------------------------------------------------------- */

.experience-list {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.role {
  border-left: 2px solid var(--color-border);
  padding-left: 1.25rem;
  position: relative;
}

.role-header {
  margin-bottom: 0.5rem;
}

.role-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.3;
}

.role-company {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-link);
}

.role-meta {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 0.15rem;
}

.role-bullets {
  list-style: disc;
  padding-left: 1.25rem;
  margin-top: 0.5rem;
}

.role-bullets li {
  font-size: 0.92rem;
  margin-bottom: 0.4rem;
  color: var(--color-text);
  line-height: 1.6;
}

/* --------------------------------------------------------------------------
   8b. Experience Disclosure (Show More / Show Less)
   -------------------------------------------------------------------------- */

.experience-expand {
  margin-top: 1.5rem;
}

.toggle-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-link);
  background-color: var(--color-specs-bg);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 0.55rem 0.9rem;
  cursor: pointer;
  user-select: none;
  list-style: none;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.toggle-button::-webkit-details-marker {
  display: none;
}

.toggle-button:hover,
.toggle-button:focus-visible {
  background-color: #e2e8f0;
  border-color: #cbd5e1;
  color: var(--color-link-hover);
  outline: 2px solid var(--color-link);
  outline-offset: 1px;
}

.experience-expand .collapse-text {
  display: none;
}

.experience-expand[open] .expand-text {
  display: none;
}

.experience-expand[open] .collapse-text {
  display: inline;
}

.detailed-experience {
  margin-top: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

/* --------------------------------------------------------------------------
   9. Projects
   -------------------------------------------------------------------------- */

.project {
  margin-bottom: 1.5rem;
}

.project h3 {
  margin-bottom: 0.25rem;
}

.project h3 a {
  text-decoration-thickness: 1px;
}

.project-tag {
  font-weight: 400;
  font-size: 0.82rem;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
}

.project p {
  margin-bottom: 0.35rem;
  color: var(--color-text);
  font-size: 0.92rem;
  line-height: 1.6;
}

.project-tech {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--color-text-muted);
}


/* --------------------------------------------------------------------------
   10. Skills Grid & Groups
   -------------------------------------------------------------------------- */

.skills-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
  margin-top: 0.5rem;
}

.skill-group h3 {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 0.4rem;
  font-family: var(--font-mono);
}

.skill-group ul {
  list-style: none;
}

.skill-group li {
  font-size: 0.9rem;
  padding: 0.2rem 0;
  line-height: 1.5;
}

.skill-group li strong {
  font-weight: 600;
}


/* --------------------------------------------------------------------------
   11. Education & Certifications
   -------------------------------------------------------------------------- */

.edu-item {
  margin-bottom: 1.25rem;
}

.edu-title {
  font-size: 1rem;
  font-weight: 700;
}

.edu-school {
  font-size: 0.92rem;
  color: var(--color-text);
  font-weight: 500;
}

.edu-meta {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.cert-list {
  list-style: disc;
  padding-left: 1.25rem;
  margin-top: 0.5rem;
}

.cert-list li {
  font-size: 0.92rem;
  margin-bottom: 0.35rem;
}


/* --------------------------------------------------------------------------
   12. Contact
   -------------------------------------------------------------------------- */

.contact-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.contact-list li {
  font-size: 0.92rem;
}

.contact-label {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--color-text-muted);
  display: inline-block;
  min-width: 80px;
}


/* --------------------------------------------------------------------------
   13. Footer
   -------------------------------------------------------------------------- */

.site-footer {
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: 1.5rem var(--content-padding);
  border-top: 1px solid var(--color-border);
  font-size: 0.82rem;
  color: var(--color-text-muted);
  text-align: center;
}


/* --------------------------------------------------------------------------
   14. Responsive — Tablet (≤768px)
   -------------------------------------------------------------------------- */

@media (max-width: 768px) {
  .header-inner {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }

  .system-specs {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    align-self: stretch;
    box-sizing: border-box;
    margin-top: 0.25rem;
  }

  .system-specs li {
    white-space: normal;
  }

  .skills-grid {
    grid-template-columns: 1fr;
  }
}


/* --------------------------------------------------------------------------
   15. Responsive — Mobile (≤480px)
   -------------------------------------------------------------------------- */

@media (max-width: 480px) {
  :root {
    --content-padding: 1rem;
  }

  .site-title {
    font-size: 1.4rem;
  }

  .site-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 0.85rem;
  }

  .system-specs {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    align-self: stretch;
    box-sizing: border-box;
    padding: 0.75rem 0.85rem;
    margin-top: 0.35rem;
  }

  .system-specs li {
    white-space: normal;
    word-break: break-word;
  }

  .skills-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .contact-list {
    flex-direction: column;
    gap: 0.5rem;
  }

  .toggle-button {
    width: 100%;
    justify-content: center;
  }

  .audit-dialog {
    width: 95vw;
    height: 90vh;
    border-radius: 6px;
  }

  .dialog-header {
    padding: 0.65rem 0.85rem;
  }

  .dialog-header h2 {
    font-size: 0.85rem;
  }

  .dialog-actions {
    gap: 0.5rem;
  }
}


/* --------------------------------------------------------------------------
   16. Print Styles
   -------------------------------------------------------------------------- */

@media print {
  .site-header {
    background: none;
    color: #000;
  }

  .system-specs,
  .skip-link,
  .site-nav,
  .experience-expand summary {
    display: none !important;
  }

  .experience-expand {
    display: block !important;
  }

  .detailed-experience {
    display: flex !important;
  }

  a {
    color: #000;
    text-decoration: underline;
  }

  a::after {
    content: ' (' attr(href) ')';
    font-size: 0.8em;
    color: #555;
  }
}


/* --------------------------------------------------------------------------
   17. Internationalization (i18n)
   -------------------------------------------------------------------------- */

html[lang="en"] [data-lang="es"] {
  display: none !important;
}

html[lang="es"] [data-lang="en"] {
  display: none !important;
}

/* In Spanish, always break language and theme switch controls onto a new line */
html[lang="es"] .nav-controls {
  flex-basis: 100%;
  width: 100%;
  margin-top: 0.35rem;
}

