/* =========================================================
   ABOUT POPUP (.about-popup)
   Full width / full height, no margins, two columns:
   [ photo space | extended text ]
   Glass look (same language as .glass in styles.css), but with
   its own rules so the browser's <dialog> defaults don't leak in.
========================================================= */

/* Keep the page from scrolling behind any open dialog */
html:has(dialog[open]) {
  overflow: hidden;
}

.about-popup {
  /* glow colors follow the theme, like .glass */
  --popup-glow-a: rgba(0, 255, 255, 0.35);
  --popup-glow-b: rgba(255, 0, 255, 0.28);

  /* reset dialog defaults (UA) */
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  overflow: hidden;

  color: var(--accent-color);
  font-family: var(--font-body);
  line-height: var(--lh-base);

  /* glass: translucent tint + blur of the page behind
     (tunable per popup: see .about-popup--dense) */
  --popup-tint: rgba(255, 255, 255, 0.16);
  --popup-blur: 28px;
  background: var(--popup-tint);
  backdrop-filter: blur(var(--popup-blur)) saturate(140%);
  -webkit-backdrop-filter: blur(var(--popup-blur)) saturate(140%);
  outline: 3px solid rgba(255, 255, 255, 0.033);
  outline-offset: -1.5px;

  &[open] {
    display: grid;
    /* photo column never wider than 4:5 of the height (the photo's ratio):
       on wide screens the photo shows whole, the text takes the rest */
    grid-template-columns: minmax(0, min(50vw, 80dvh)) minmax(0, 1fr);
    /* explicit row: the photo's intrinsic height never stretches the dialog */
    grid-template-rows: minmax(0, 1fr);
  }

  &::backdrop {
    background: transparent;
  }

  /* soft color glows, as in .glass (absolutely positioned → not grid items) */
  &::before,
  &::after {
    content: "";
    position: absolute;
    z-index: 0;
    width: 60vmax;
    height: 60vmax;
    filter: blur(80px);
    opacity: 0.22;
    pointer-events: none;
  }
  &::before {
    top: -25vmax;
    left: -20vmax;
    background: radial-gradient(circle, var(--popup-glow-a), transparent 70%);
  }
  &::after {
    right: -20vmax;
    bottom: -25vmax;
    background: radial-gradient(circle, var(--popup-glow-b), transparent 70%);
  }
}

.dark .about-popup {
  --popup-glow-a: rgba(0, 255, 119, 0.35);
  --popup-glow-b: rgba(132, 0, 255, 0.28);
  --popup-tint: rgba(0, 0, 0, 0.32);
  outline: 2.5px solid rgba(255, 255, 255, 0.02);
}

/* Reading popup ("Sobre mí"): denser glass so the page behind (the
   avatar) doesn't compete with the text */
.about-popup--dense {
  --popup-tint: rgba(255, 255, 255, 0.55);
  --popup-blur: 48px;
}
.dark .about-popup--dense {
  --popup-tint: rgba(0, 0, 0, 0.66);
}

/* ---------- Column 1: photo (4:5 portrait) ---------- */
.about-popup__media {
  /* framing when the box crops the photo (narrow desktop columns, the
     strip on portrait screens). Tune here: x/y as in object-position;
     y 25% keeps the whole head in the landscape strip. */
  --photo-x: 55%;
  --photo-y: 25%;

  position: relative;
  z-index: 1;
  background: var(--surface-light-color);
  border-right: 1px solid var(--line-color);
  overflow: hidden;

  img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: var(--photo-x) var(--photo-y);
  }
}

/* ---------- Column 2: extended text ---------- */
.about-popup__content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: clamp(4.5rem, 10vh, 6rem) clamp(1.5rem, 5vw, 4.5rem);
}

/* auto margins center the text vertically without clipping it when it overflows */
.about-popup__text {
  margin-block: auto;
  max-inline-size: 60ch;

  h2 {
    font-size: var(--fs-1);
    margin-bottom: 0.6em;
  }

  p {
    margin-bottom: 1em;
    font-size: var(--fs-5);
    color: color-mix(in srgb, var(--accent-color) 86%, transparent);
    text-wrap: pretty;
    &:last-child {
      margin-bottom: 0;
    }
  }

  /* opening paragraph: the summary already seen in the section */
  .lead {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    font-size: var(--fs-4);
    line-height: 1.5;
    color: var(--accent-color);
    border-bottom: 1px solid var(--line-color);
  }
}

/* ---------- Close button (.dialog-close), shared by every dialog: same look as the mobile menu button ---------- */
.dialog-close {
  position: absolute;
  z-index: 2;
  top: clamp(1rem, 3vw, 2rem);
  right: clamp(1rem, 3vw, 2rem);
  display: grid;
  place-items: center;
  /* no padding: the icon's hover background fills the whole button (no ring) */
  padding: 0;
  color: var(--accent-color);
  background: var(--surface-light-color);
  backdrop-filter: blur(100px);
  -webkit-backdrop-filter: blur(100px);
  border: 0;
  border-radius: var(--radius-chip);
  cursor: pointer;

  i {
    display: block;
    padding: 0.5rem;
    font-size: 2rem;
    line-height: 1;
    opacity: 0.6;
    border-radius: var(--radius-chip);
    transition: opacity 0.25s ease-out, background-color 0.25s ease-out;
  }

  &:hover i,
  &:focus-visible i {
    opacity: 1;
    background: var(--surface-color);
  }

  &:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
  }
}

/* ---------- Sheet handle (.sheet-handle), shared by the bottom sheets ----------
   Drag it down to close the sheet (js/ui/sheet-drag.js). Only on narrow
   screens, where the CV popup and the drawers become bottom sheets.
   Decorative for assistive tech: Esc and the close button do the same. */
.sheet-handle {
  display: none;
}
@media (max-width: 600px) {
  .sheet-handle {
    position: absolute;
    z-index: 2;
    top: 0;
    left: 50%;
    translate: -50% 0;
    display: grid;
    place-items: center;
    /* generous touch area around a small bar */
    width: 7rem;
    height: 1.75rem;
    touch-action: none;
    cursor: grab;
    &::before {
      content: "";
      width: 2.25rem;
      height: 0.25rem;
      border-radius: 1rem;
      background: currentColor;
      opacity: 0.25;
    }
    &:active {
      cursor: grabbing;
    }
  }
}

/* ---------- Portrait screens (phones, tablets): photo on top, text below ----------
   By shape, not width: a portrait tablet would otherwise get a very thin
   column, and a landscape phone a ~6:1 strip (it keeps two columns instead).
   The strip grows with the width: between 4:3 (phone) and ~5:3 (tablet). */
@media (max-aspect-ratio: 1/1) {
  .about-popup[open] {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, min(75vw, 42dvh)) minmax(0, 1fr);
  }
  .about-popup__media {
    border-right: 0;
    border-bottom: 1px solid var(--line-color);
  }
  .about-popup__content {
    padding-top: 2rem;
  }
}

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  .about-popup[open] {
    animation: about-popup-in 0.25s ease-out;
  }
}

@keyframes about-popup-in {
  from {
    opacity: 0;
  }
}
