/* ==========================================================================
   Miguel Ángel Villafán González — CV
   Light, paper-like theme. One accent (deep navy-blue).
   ========================================================================== */

:root {
  --paper: #f6f4ef;
  --card: #ffffff;
  --ink: #1b1f24;
  --ink-soft: #3a3f47;
  --muted: #6b7280;
  --accent: #163a5f;
  --accent-tint: #e7edf5;
  --accent-tint-strong: #d7e2ef;
  --ring: #d9d4c8;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --shadow-card: 0 1px 2px rgba(27, 31, 36, 0.04), 0 12px 32px rgba(27, 31, 36, 0.06);
  --shadow-modal: 0 24px 64px rgba(15, 20, 28, 0.35);
  --font-display: "Fraunces", "Playfair Display", Georgia, "Times New Roman", serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  padding-block: 32px;
  padding-inline: 16px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
}

.page {
  display: flex;
  justify-content: center;
}

.card {
  width: 100%;
  max-width: 1040px;
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

/* -------------------------------- Header -------------------------------- */

.header {
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 40px clamp(20px, 4vw, 48px);
  border-bottom: 1px solid var(--ring);
}

.header-text {
  flex: 1;
  min-width: 0;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.name {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.6rem, 3.6vw, 2.4rem);
  line-height: 1.15;
  color: var(--ink);
  letter-spacing: 0.01em;
}

.tagline {
  margin: 0 0 18px;
  color: var(--ink-soft);
  font-size: 1rem;
}

.contact-row {
  list-style: none;
  margin: 0 0 22px;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
}

.contact-row li a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.contact-row li a:hover,
.contact-row li a:focus-visible {
  color: var(--accent);
}

.contact-row svg {
  flex-shrink: 0;
  color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.btn-download {
  background: var(--accent);
  color: #ffffff;
  padding: 12px 20px;
}

.btn-download:hover,
.btn-download:focus-visible {
  background: #102b47;
}

.btn-ghost {
  background: var(--accent-tint);
  color: var(--accent);
  padding: 8px 14px;
  font-size: 0.85rem;
}

.btn-ghost:hover,
.btn-ghost:focus-visible {
  background: var(--accent-tint-strong);
}

.btn-sm {
  padding: 6px 10px;
  font-size: 0.78rem;
}

.header-photo {
  flex-shrink: 0;
}

.header-photo img {
  width: 148px;
  height: 184px;
  object-fit: cover;
  border-radius: var(--radius-md);
  border: 3px solid var(--card);
  outline: 2px solid var(--ring);
  outline-offset: 0;
}

/* -------------------------------- Layout -------------------------------- */

.content {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 40px;
  padding: 40px clamp(20px, 4vw, 48px);
}

.main,
.aside {
  min-width: 0;
}

.section {
  margin-bottom: 36px;
}

.section:last-child {
  margin-bottom: 0;
}

.section-title {
  margin: 0 0 16px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--ring);
}

.profile-text {
  margin: 0;
  color: var(--ink-soft);
}

/* ------------------------------- Timeline -------------------------------- */

.timeline {
  list-style: none;
  margin: 0;
  padding: 0 0 0 22px;
  border-left: 2px solid var(--accent-tint-strong);
}

.timeline-item {
  position: relative;
  padding-bottom: 28px;
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: -27px;
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.period {
  margin: 0 0 4px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.company {
  margin: 0 0 4px;
  font-size: 1.02rem;
  font-weight: 600;
}

.company-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: transparent;
  transition: text-decoration-color 0.15s ease, color 0.15s ease;
}

.company-link:hover,
.company-link:focus-visible {
  text-decoration-color: currentColor;
}

.company-link .ext-icon {
  color: var(--muted);
  transition: color 0.15s ease;
}

.company-link:hover .ext-icon,
.company-link:focus-visible .ext-icon {
  color: var(--accent);
}

/* Tooltip via CSS pseudo-element, reading data attributes directly */
.company-link::after {
  content: attr(data-company) " · " attr(data-domain);
  position: absolute;
  left: 50%;
  bottom: 100%;
  margin-bottom: 8px;
  transform: translate(-50%, 4px);
  background: var(--ink);
  color: #ffffff;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 5;
}

.company-link:hover::after,
.company-link:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.role {
  margin: 0 0 6px;
  color: var(--ink-soft);
}

.bullets {
  margin: 0;
  padding-left: 18px;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.bullets li {
  margin-bottom: 2px;
}

/* --------------------------------- Aside ---------------------------------- */

.plain-list {
  margin: 0;
  padding-left: 18px;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.plain-list li {
  margin-bottom: 6px;
}

.languages {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.languages li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.92rem;
}

.lang-label {
  color: var(--ink);
  font-weight: 500;
}

.lang-level {
  color: var(--muted);
}

.chips {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chips li {
  background: var(--accent-tint);
  color: var(--accent);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
}

.quote {
  margin: 0;
  padding: 18px 20px;
  background: var(--accent-tint);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-style: italic;
  font-size: 0.92rem;
}

/* -------------------------------- Footer ---------------------------------- */

.footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px clamp(20px, 4vw, 48px);
  border-top: 1px solid var(--ring);
  color: var(--muted);
  font-size: 0.82rem;
}

.footer p {
  margin: 0;
}

.footer a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* -------------------------------- Modal ------------------------------------ */

.modal {
  width: min(1100px, calc(100vw - 32px));
  height: 85vh;
  max-height: 85vh;
  padding: 0;
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  flex-direction: column;
  overflow: hidden;
}

/* Only lay out the dialog when it is open; a closed <dialog> must stay hidden. */
.modal[open] {
  display: flex;
}

.modal::backdrop {
  background: rgba(15, 20, 28, 0.55);
  backdrop-filter: blur(4px);
}

.modal[open] {
  animation: modal-in 200ms ease-out;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .modal[open] {
    animation: none;
  }
}

.modal-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--ring);
  flex-shrink: 0;
}

.modal-title-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.modal-company-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-domain {
  font-size: 0.8rem;
  color: var(--muted);
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.modal-close:hover,
.modal-close:focus-visible {
  color: var(--ink);
  background: var(--accent-tint);
}

.modal-notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 20px;
  background: #fbf3d9;
  color: #6b5410;
  font-size: 0.85rem;
  border-bottom: 1px solid #f0e3ad;
  flex-shrink: 0;
}

.modal-body {
  flex: 1;
  min-height: 0;
}

.modal-body iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* ------------------------------- Focus states ------------------------------ */

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* -------------------------------- Responsive -------------------------------- */

@media (max-width: 800px) {
  .content {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  .header {
    flex-direction: column-reverse;
    align-items: flex-start;
    gap: 20px;
  }

  .header-photo img {
    width: 120px;
    height: 149px;
  }
}

@media (max-width: 480px) {
  .modal-titlebar {
    flex-wrap: wrap;
  }
}

/* ---------------------------------- Print ----------------------------------- */

@media print {
  body {
    background: #ffffff;
    padding: 0;
  }

  .card {
    box-shadow: none;
    border-radius: 0;
  }

  .btn-download,
  .footer a {
    display: none;
  }

  .company-link::after {
    display: none;
  }

  .company-link::before {
    content: " (" attr(data-url) ")";
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 400;
    text-decoration: none;
  }

  .ext-icon {
    display: none;
  }

  dialog {
    display: none !important;
  }
}
