/* El escritorio conserva sus hojas originales. */
.menu-toggle {
  display: none;
}

@media screen and (max-width: 1024px) {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  body {
    --page-background: #F5F5F5;
    --page-color: #383838;
    --page-gutter: 24px;
    padding-top: 64px;
  }

  body[data-page="sobre-mi"] {
    --page-background: #F9FF3E;
  }

  body[data-page="contacto"] {
    --page-background: #0600a0;
    --page-color: #F9FF3E;
    padding-top: 0;
  }

  body[data-page="galeria"] {
    padding-top: 0;
  }

  header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    height: 64px;
    top: 0;
    padding-inline: var(--page-gutter);
    color: var(--page-color);
    background: var(--page-background);
    mix-blend-mode: normal !important;
    filter: none !important;
  }

  header > nav:first-child {
    grid-column: 1;
    grid-row: 1;
    width: auto;
  }

  #ul-izquierda {
    padding: 0;
    gap: 0;
  }

  #una-header {
    padding: 0;
    font-size: 28px;
  }

  header > a {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 54px;
    min-height: 44px;
  }

  header svg {
    filter: none;
    width: 44px;
  }

  header svg path {
    fill: currentColor;
    mix-blend-mode: normal !important;
  }

  .menu-toggle {
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font-family: 'Helvena-Medium';
    font-size: 13px;
    cursor: pointer;
  }

  .menu-mark {
    font-size: 24px;
    line-height: 1;
  }

  header > nav:last-of-type {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    max-height: calc(100dvh - 64px);
    overflow-y: auto;
    padding: 12px var(--page-gutter) 24px;
    background: var(--page-background);
    border-top: 1px solid currentColor;
  }

  header[data-menu-open] > nav:last-of-type {
    display: block;
  }

  #ul-derecha {
    display: grid;
    gap: 4px;
    padding: 0;
    height: auto;
    justify-content: stretch;
  }

  #ul-derecha a {
    display: flex;
    align-items: center;
    min-height: 48px;
    padding: 10px 12px;
    font-size: 16px;
  }

  body[data-page="contacto"] header .pageon_selected {
    color: #0600a0;
  }

  header a:focus-visible,
  .menu-toggle:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 3px;
  }

  #disponible {
    top: 64px;
    width: 100%;
    height: 48px;
    padding: 0 var(--page-gutter);
  }

  .version-escritorio {
    display: none;
  }

  main img,
  main video {
    max-width: 100%;
    height: auto;
  }

  .tag_container,
  .tag-detalle-trabajo {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .tag_container p,
  p.tag {
    max-width: 100%;
    font-size: 12px;
  }

  /* Inicio: las fichas se pueden leer y abrir sin hover. */
  body[data-page="index"] #video_box {
    position: relative;
    top: auto;
    height: calc(100vh - 64px);
    height: calc(100dvh - 64px);
  }

  body[data-page="index"] #inicio {
    display: block;
    width: 100%;
    height: 100%;
  }

  body[data-page="index"] #trabajos {
    padding: var(--page-gutter);
    gap: 32px;
  }

  body[data-page="index"] #texto_inicio {
    font-size: clamp(24px, 3.8vw, 38px);
    line-height: 1.15;
  }

  body[data-page="index"] #texto_inicio br,
  .info_item br {
    display: none;
  }

  .trabajos_item {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 32px;
  }

  .trabajos_item > * {
    width: auto;
    min-width: 0;
    grid-column: span 3;
  }

  .trabajos_item > .hijo_3 {
    grid-column: span 2;
  }

  .trabajos_item > .hijo_4,
  .trabajos_item > .hijo_6 {
    grid-column: 1 / -1;
  }

  .trabajos_item img {
    display: block;
    width: 100%;
    height: auto;
  }

  .trabajos_item .info_item,
  #info_item_lateral_izquierdo,
  #info_item_lateral_derecha {
    position: static;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: auto;
    margin: 0;
    padding: 16px;
    gap: 12px;
    opacity: 1;
  }

  .info_item_left,
  .info_item_right {
    width: 100%;
    height: auto;
    gap: 8px;
  }

  .info_item_left h4 {
    padding: 0 !important;
    font-size: 17px;
    line-height: 1.2;
  }

  .info_item_left p {
    font-size: 14px;
    line-height: 1.45;
  }

  .type_container p {
    font-size: 12px;
  }

  /* Trabajos: dos columnas en tablet, una en telefonos. */
  .trabajos-general {
    padding: var(--page-gutter);
    gap: 32px;
  }

  .seccion {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
  }

  .titular-trabajo {
    flex-direction: column;
    align-items: flex-start;
    font-size: 16px;
  }

  .titular-trabajo h4 {
    margin: 14px 0 8px;
    line-height: 1.3;
  }

  .titular-trabajo .tag_container p {
    margin: 0;
  }

  /* Sobre mi: la columna fija pasa al flujo cuando falta espacio. */
  .contenedor-general {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 32px;
    padding: var(--page-gutter);
  }

  .left,
  .right {
    position: static;
    width: auto;
    min-width: 0;
    margin: 0;
  }

  .retrato-img {
    width: 100%;
    height: auto;
    max-width: 390px;
    max-height: none;
  }

  .info-izquierda {
    gap: 16px;
  }

  .contacto h2,
  .title-info h2,
  .software h2 {
    font-size: 20px;
  }

  .introduccion {
    font-size: clamp(20px, 2.6vw, 24px);
    line-height: 1.35;
  }

  .software-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }

  .software-list ul {
    margin: 0;
  }

  .software-list li {
    font-size: 14px;
    line-height: 1.5;
  }

  .elementos-educacion {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 2fr);
    gap: 4px 16px;
    font-size: 14px;
    line-height: 1.45;
  }

  .fechas,
  .info-estudios {
    display: contents;
  }

  .elementos-educacion br {
    display: none;
  }

  .fechas p:first-of-type {
    grid-column: 1;
    grid-row: 1 / 3;
  }

  .fechas p:nth-of-type(2) {
    grid-column: 1;
    grid-row: 3 / 5;
    margin-top: 20px;
  }

  .info-estudios p {
    grid-column: 2;
  }

  .info-estudios p:nth-of-type(1) { grid-row: 1; }
  .info-estudios p:nth-of-type(2) { grid-row: 2; }
  .info-estudios p:nth-of-type(3) { grid-row: 3; margin-top: 20px; }
  .info-estudios p:nth-of-type(4) { grid-row: 4; }

  /* Detalles: las piezas conservan su proporcion original. */
  #img1_box {
    position: relative;
    top: auto;
  }

  #proyecto_1 {
    display: block;
    width: 100%;
  }

  body[data-page="proyecto"] #trabajos {
    padding: 0;
  }

  #textos_info {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: var(--page-gutter);
    gap: 24px;
  }

  #textos_info > * {
    min-width: 0;
  }

  #textos_info .info_derecha {
    grid-column: 1 / -1;
  }

  .info_izquierda h3 {
    margin: 0 0 16px;
    font-size: clamp(24px, 3vw, 32px);
    line-height: 1.15;
  }

  .info_centro h3,
  .info_derecha h3 {
    display: none;
  }

  .info_izquierda p,
  .info_centro p {
    font-size: 16px;
    line-height: 1.5;
    margin: 0 0 20px;
  }

  .info_derecha .tag_container p {
    margin: 0;
  }

  .seccion1_trabajos,
  .seccion1_trabajos_fanzines {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: var(--page-gutter);
    gap: 24px;
  }

  .detalletrabajos {
    width: 100%;
    height: auto;
    min-width: 0;
    flex-direction: column;
  }

  .detalletrabajos img,
  .detalletrabajos video {
    width: 100%;
    height: auto;
  }

  #detalle-caja {
    padding-top: 24px;
  }

  #raton-revista-grande img {
    width: 100%;
    padding-bottom: 0;
  }

  /* Footer: mismo amarillo, sin deformar la imagen de escritorio. */
  footer {
    width: 100%;
    padding: var(--page-gutter);
  }

  #footer-info {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
    height: auto;
    padding: 24px;
    gap: 24px;
    background: #F9FF3E;
  }

  .footer-item,
  .footer-item-datos {
    width: 100%;
    height: auto;
    min-width: 0;
  }

  .footer-item {
    justify-content: flex-start;
  }

  .footer-item div h2 {
    margin: 0;
    font-size: clamp(20px, 2.6vw, 28px);
    line-height: 1.1;
  }

  .footer-item h2[style*="opacity: 0"] {
    display: none;
  }

  .footer-item div p {
    line-height: 1.5;
    overflow-wrap: anywhere;
  }

  #footer-secciones {
    gap: 20px;
    flex-wrap: wrap;
    line-height: 1.8;
  }

  .footer-end {
    height: auto;
    margin-top: auto;
    padding: 20px 0 0;
    color: #535708;
    font-size: 12px;
  }

  /* Contacto: dos lineas al pie, con margen a ambos lados. */
  .contacto-principal {
    --contacto-margen: 10px;
    padding-top: 96px;
    padding-bottom: max(40px, env(safe-area-inset-bottom));
  }

  .contacto-dato {
    width: 100%;
    margin-inline: 0;
    font-size: calc((100vw - 20px) / var(--ancho-texto));
  }

  @supports (container-type: inline-size) {
    .contacto-dato {
      font-size: calc(100cqw / var(--ancho-texto));
    }
  }

  /* Galeria: una columna continua, con movimiento vertical. */
  #gallery {
    position: relative;
    top: 64px;
    touch-action: none;
    cursor: grab;
  }

  .linea {
    flex-direction: column;
  }

  .photo {
    flex: none;
    width: 100%;
    height: var(--gallery-item-height);
  }

  .photo .photo_tittle,
  .photo:hover .photo_tittle {
    display: none;
  }

  #gallery[data-dragging] {
    cursor: grabbing;
  }

  #gallery-hint {
    max-width: calc(100% - 32px);
    bottom: max(20px, env(safe-area-inset-bottom));
  }

  .photo img {
    padding: 16px;
    width: 100%;
    height: 100%;
    transition: none;
  }
}

@media screen and (max-width: 768px) {
  body { --page-gutter: 20px; }

  .trabajos_item,
  .contenedor-general,
  #textos_info,
  .seccion1_trabajos,
  .seccion1_trabajos_fanzines {
    grid-template-columns: minmax(0, 1fr);
  }

  .trabajos_item > * {
    grid-column: 1 / -1;
  }

  body[data-page="index"] #texto_inicio {
    font-size: clamp(24px, 6.5vw, 36px);
  }

  .contenedor-general {
    gap: 40px;
  }

  .introduccion {
    font-size: 22px;
  }

  .ver-trabajo {
    opacity: 1;
  }
}

@media screen and (max-width: 600px) {
  #disponible {
    display: none;
  }

  .seccion,
  #footer-info {
    grid-template-columns: minmax(0, 1fr);
  }

  .seccion {
    gap: 32px;
  }

  .trabajos-general {
    gap: 32px;
  }

  footer {
    padding: 20px;
  }

  #footer-info {
    padding: 24px 20px;
    gap: 32px;
  }

  .footer-item div h4 {
    margin-top: 16px;
  }
}

@media screen and (max-width: 400px) {
  .software-list {
    grid-template-columns: minmax(0, 1fr);
  }

  .introduccion {
    font-size: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .menu-toggle,
  #gallery-hint {
    transition: none;
  }
}
