/* IArt.digital — sala blanca de museo.
   La obra pone el color; todo lo demás es pared, cartela y silencio. */

:root {
  --wall: #ececea;
  --paper: #ffffff;
  --ink: #15151a;
  --ink-2: #53535c;
  --line: #d3d3cf;
  --accent: #2431d6;
  --accent-ink: #ffffff;
  --accent-soft: rgba(36, 49, 214, 0.1);
  --danger: #b3261e;
  --ok: #1d6b3a;
  --shadow: 0 1px 2px rgba(20, 20, 30, 0.08), 0 22px 44px -22px rgba(20, 20, 30, 0.4);
  /* Tipografía Apple (San Francisco) en iPhone, iPad y Mac; en otros sistemas, su equivalente nativo. */
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", system-ui, "Segoe UI", Roboto, Arial, sans-serif;
  --serif: var(--sans);
  --gutter: clamp(16px, 3.2vw, 40px);
  --maxw: 1520px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --wall: #0f0f13;
    --paper: #1a1a20;
    --ink: #ededf0;
    --ink-2: #a3a3ae;
    --line: #2d2d37;
    --accent: #8a93ff;
    --accent-ink: #0f0f13;
    --accent-soft: rgba(138, 147, 255, 0.14);
    --danger: #ff8a80;
    --ok: #7bd69b;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 26px 50px -22px rgba(0, 0, 0, 0.9);
  }
}

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

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

body {
  margin: 0;
  background: var(--wall);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.55;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); text-underline-offset: 0.18em; }
a:hover { text-decoration-color: currentColor; }
h1, h2, h3 { font-family: var(--sans); font-weight: 700; line-height: 1.1; letter-spacing: -0.022em; margin: 0 0 0.5em; text-wrap: balance; }
h1 { font-size: clamp(2rem, 4.4vw, 3.4rem); }
h2 { font-size: clamp(1.4rem, 2.4vw, 1.9rem); }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; text-wrap: pretty; }
.muted { color: var(--ink-2); }
.small { font-size: 0.875rem; }
.nowrap { white-space: nowrap; }

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

.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding-left: max(var(--gutter), env(safe-area-inset-left));
  padding-right: max(var(--gutter), env(safe-area-inset-right));
}

.skip {
  position: absolute; left: -999px; top: 8px; background: var(--ink); color: var(--wall);
  padding: 10px 16px; z-index: 100; border-radius: 4px;
}
.skip:focus { left: 8px; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Cabecera ---------- */
.site-header {
  padding-top: env(safe-area-inset-top);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--wall) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 20;
}
.header-row { display: flex; align-items: center; gap: 12px 24px; flex-wrap: wrap; padding-top: 12px; padding-bottom: 12px; }
.brand { font-family: var(--sans); font-size: 1.65rem; font-weight: 700; letter-spacing: -0.04em; text-decoration: none; line-height: 1; }
.brand span { color: var(--accent); }
.brand small { font-family: var(--sans); font-size: 0.75rem; font-weight: 500; letter-spacing: 0; color: var(--ink-2); margin-left: 2px; }

.main-nav { display: flex; align-items: center; gap: 4px 18px; flex-wrap: wrap; }
.main-nav a, .main-nav button.linklike {
  text-decoration: none; padding: 10px 2px; min-height: 44px; display: inline-flex; align-items: center;
  font-size: 0.95rem; color: var(--ink-2);
}
.main-nav a:hover, .main-nav a[aria-current="page"], .main-nav button.linklike:hover { color: var(--ink); }
.main-nav a[aria-current="page"] { box-shadow: inset 0 -2px 0 var(--accent); }

.header-spacer { flex: 1 1 0; }
.header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.search { display: flex; align-items: center; min-width: 0; }
.search input {
  width: clamp(150px, 20vw, 260px); min-height: 44px; padding: 0 14px; border: 1px solid var(--line);
  border-radius: 999px; background: var(--paper); color: var(--ink); font: inherit; font-size: 0.95rem;
}

.menu-user { position: relative; }
.menu-user summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; min-height: 44px; }
.menu-user summary::-webkit-details-marker { display: none; }
.menu-user .menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; background: var(--paper);
  border: 1px solid var(--line); box-shadow: var(--shadow); padding: 8px; z-index: 30;
}
.menu-user .menu a, .menu-user .menu button {
  display: flex; width: 100%; padding: 11px 12px; min-height: 44px; align-items: center; text-decoration: none;
  color: var(--ink); background: none; border: 0; font: inherit; text-align: left; cursor: pointer;
}
.menu-user .menu a:hover, .menu-user .menu button:hover { background: var(--accent-soft); }

.avatar {
  width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: var(--accent-soft);
  display: inline-grid; place-items: center; font-family: var(--serif); font-weight: 700; color: var(--accent);
  flex: none;
}
.avatar.lg { width: 96px; height: 96px; font-size: 2.4rem; }

/* ---------- Botones y formularios ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 20px;
  border-radius: 999px; border: 1px solid var(--ink); background: transparent; color: var(--ink);
  font: inherit; font-size: 0.95rem; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--ink); color: var(--wall); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.1); background: var(--accent); color: var(--accent-ink); }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: var(--wall); }
.btn.small { min-height: 38px; padding: 0 14px; font-size: 0.875rem; }
button.linklike { background: none; border: 0; font: inherit; cursor: pointer; color: inherit; padding: 0; }

.field { margin-bottom: 18px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; }
.field .help { color: var(--ink-2); font-size: 0.875rem; margin-top: 5px; }
.field .error, .errorlist { color: var(--danger); font-size: 0.9rem; margin: 6px 0 0; padding: 0; list-style: none; }
.field-check { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.field-check input { margin-top: 5px; width: 20px; height: 20px; flex: none; accent-color: var(--accent); }
.field-check label { font-weight: 400; }

input[type="text"], input[type="email"], input[type="password"], input[type="url"], input[type="search"],
select, textarea {
  width: 100%; min-height: 46px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--paper); color: var(--ink); font: inherit; font-size: 1rem; /* 16px: evita el zoom en iPhone */
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input[type="file"] { font: inherit; font-size: 0.95rem; color: var(--ink-2); max-width: 100%; }
input[type="file"]::file-selector-button {
  min-height: 40px; padding: 0 18px; margin-right: 14px; border-radius: 999px; border: 1px solid var(--ink);
  background: transparent; color: var(--ink); font: inherit; font-size: 0.95rem; font-weight: 600; cursor: pointer;
}
input[type="file"]::file-selector-button:hover { background: var(--ink); color: var(--wall); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.form-card {
  background: var(--paper); padding: clamp(22px, 4vw, 40px); box-shadow: var(--shadow); max-width: 560px; margin: 0 auto;
}
.form-card.wide { max-width: 860px; }
.form-card h1 { font-size: clamp(1.7rem, 3.2vw, 2.4rem); }
.form-links { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: 0.95rem; }
.form-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 24px; }

/* ---------- Mensajes ---------- */
.messages { list-style: none; margin: 0; padding: 0; }
.messages li {
  padding: 14px var(--gutter); background: var(--ink); color: var(--wall); font-size: 0.95rem;
}
.messages li.success { background: var(--ok); color: #fff; }
.messages li.error { background: var(--danger); color: #fff; }
@media (prefers-color-scheme: dark) {
  .messages li.success, .messages li.error { color: #0f0f13; }
}

/* ---------- Estructura ---------- */
main { flex: 1 0 auto; padding-top: clamp(24px, 4vw, 48px); padding-bottom: clamp(48px, 7vw, 96px); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; margin-bottom: 18px; }
.section-head h2 { margin: 0; }

/* ---------- Portada ---------- */
.hero {
  display: grid; gap: clamp(24px, 4vw, 64px); align-items: center; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  margin-bottom: clamp(40px, 6vw, 80px);
}
.hero-text h1 { font-size: clamp(2.3rem, 5.2vw, 4.4rem); font-weight: 700; letter-spacing: -0.035em; line-height: 1.05; margin-bottom: 0.35em; }
.hero-text p { font-size: 1.15rem; color: var(--ink-2); max-width: 34ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }

/* El marco: la obra destacada colgada con paspartú y cartela. */
.frame { margin: 0; background: var(--paper); padding: clamp(12px, 2vw, 22px); box-shadow: var(--shadow); }
.frame-img { display: grid; place-items: center; background: color-mix(in srgb, var(--ink) 4%, var(--paper)); }
.frame-img img { width: auto; height: auto; max-width: 100%; max-height: min(72vh, 760px); }
.frame figcaption { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; padding-top: 14px; }
.frame .t { font-family: var(--sans); font-size: 1.2rem; font-weight: 600; letter-spacing: -0.015em; line-height: 1.2; }
.frame .t a { text-decoration: none; }

/* ---------- Filtros ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 26px; }
.chip {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--line); background: transparent; color: var(--ink); text-decoration: none; font-size: 0.9rem;
}
.chip:hover { border-color: var(--ink); }
.chip[aria-current="true"] { background: var(--ink); color: var(--wall); border-color: var(--ink); }
.filters .sep { width: 1px; height: 24px; background: var(--line); margin: 0 6px; }

/* ---------- Rejilla tipo mosaico ---------- */
.grid { column-gap: clamp(18px, 2.4vw, 32px); column-count: 1; }
@media (min-width: 560px) { .grid { column-count: 2; } }
@media (min-width: 920px) { .grid { column-count: 3; } }
@media (min-width: 1440px) { .grid { column-count: 4; } }

.piece { break-inside: avoid; margin: 0 0 clamp(26px, 3vw, 40px); }
.piece-img { display: block; background: color-mix(in srgb, var(--ink) 6%, var(--wall)); }
.piece-img img { width: 100%; height: auto; transition: filter 0.2s; }
.piece-img:hover img { filter: brightness(1.04); }
.piece figcaption { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding-top: 10px; }
.cartela { min-width: 0; line-height: 1.3; }
.cartela .t { font-family: var(--sans); font-weight: 600; font-size: 1.02rem; letter-spacing: -0.01em; display: block; overflow-wrap: anywhere; text-decoration: none; }
.cartela .by { color: var(--ink-2); font-size: 0.875rem; display: block; margin-top: 2px; }
.cartela .by a { text-decoration: none; }
.cartela .by a:hover { text-decoration: underline; }

/* ---------- Like ---------- */
.like-form { margin: 0; flex: none; }
.like {
  display: inline-flex; align-items: center; gap: 7px; min-height: 44px; min-width: 44px; padding: 0 10px; margin: -8px -10px -8px 0;
  background: none; border: 0; color: var(--ink-2); font: inherit; font-size: 0.9rem; cursor: pointer; border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.like:hover { color: var(--accent); }
.like svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; transition: transform 0.15s; }
.like[aria-pressed="true"] { color: var(--accent); }
.like[aria-pressed="true"] svg { fill: currentColor; }
.like.pop svg { transform: scale(1.25); }
.like.big { border: 1px solid var(--line); margin: 0; padding: 0 18px; font-size: 1rem; }
.like.big[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- Paginación ---------- */
.pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }

/* ---------- Detalle de obra ---------- */
.detail { display: grid; gap: clamp(24px, 4vw, 56px); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1000px) { .detail { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; } }
.detail-art { margin: 0; background: var(--paper); padding: clamp(10px, 2vw, 24px); box-shadow: var(--shadow); }
.detail-art button { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
.detail-art img { width: 100%; height: auto; max-height: 84vh; object-fit: contain; margin: 0 auto; }
.placard { background: var(--paper); padding: 26px; box-shadow: var(--shadow); }
@media (min-width: 1000px) { .placard { position: sticky; top: 96px; } }
.placard h1 { font-size: clamp(1.6rem, 2.6vw, 2.2rem); margin-bottom: 0.3em; }
.placard .artist { display: flex; align-items: center; gap: 12px; text-decoration: none; margin-bottom: 20px; }
.placard dl { margin: 18px 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; font-size: 0.95rem; }
.placard dt { color: var(--ink-2); }
.placard dd { margin: 0; }
.prompt-box { background: color-mix(in srgb, var(--ink) 5%, var(--paper)); padding: 14px 16px; font-size: 0.9rem; white-space: pre-wrap; overflow-wrap: anywhere; border-left: 3px solid var(--accent); }
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 0; padding: 0; list-style: none; }
.placard-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; align-items: center; }

dialog.lightbox {
  padding: 0; border: 0; background: rgba(8, 8, 12, 0.96); width: 100vw; height: 100vh; height: 100dvh;
  max-width: none; max-height: none; color: #fff;
}
dialog.lightbox::backdrop { background: rgba(8, 8, 12, 0.96); }
dialog.lightbox img { width: 100%; height: 100%; object-fit: contain; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
dialog.lightbox .close {
  position: fixed; top: max(14px, env(safe-area-inset-top)); right: max(14px, env(safe-area-inset-right));
  min-height: 44px; min-width: 44px; border-radius: 999px; border: 1px solid rgba(255,255,255,.4);
  background: rgba(0,0,0,.5); color: #fff; font: inherit; font-size: 1.4rem; cursor: pointer;
}

/* ---------- Galería de autor ---------- */
.artist-head { display: flex; gap: clamp(18px, 3vw, 36px); align-items: center; flex-wrap: wrap; margin-bottom: clamp(28px, 4vw, 48px); }
.artist-head h1 { margin-bottom: 0.15em; }
.artist-head .bio { max-width: 60ch; margin: 0.4em 0 0; }
.artist-stats { display: flex; gap: 22px; margin-top: 10px; color: var(--ink-2); font-size: 0.95rem; flex-wrap: wrap; }
.artist-stats b { color: var(--ink); font-variant-numeric: tabular-nums; }

.artist-card { break-inside: avoid; margin: 0 0 28px; }
.artist-card a { text-decoration: none; display: block; }
.artist-card .cover { background: color-mix(in srgb, var(--ink) 6%, var(--wall)); aspect-ratio: 4 / 3; overflow: hidden; }
.artist-card .cover img { width: 100%; height: 100%; object-fit: cover; }
.artist-card .cover.empty { display: grid; place-items: center; font-family: var(--serif); font-size: 3rem; color: var(--ink-2); }
.artist-card .t { font-family: var(--serif); font-weight: 600; font-size: 1.1rem; margin-top: 10px; display: block; }

/* ---------- Subida ---------- */
.drop {
  display: grid; place-items: center; text-align: center; gap: 6px; min-height: 220px; padding: 24px;
  border: 2px dashed var(--line); border-radius: 8px; background: color-mix(in srgb, var(--ink) 3%, var(--paper));
  cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop img { max-height: 320px; width: auto; margin: 0 auto; }
.drop-wrap { position: relative; }
.drop-wrap input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.drop-wrap input[type="file"]:focus-visible + .drop { outline: 3px solid var(--accent); outline-offset: 3px; }

/* ---------- Vacío, avisos ---------- */
.empty-state { text-align: center; padding: clamp(40px, 8vw, 96px) 0; max-width: 46ch; margin: 0 auto; }
.notice { background: var(--accent-soft); padding: 14px 18px; border-left: 3px solid var(--accent); margin-bottom: 22px; }
.prose { max-width: 70ch; background: var(--paper); padding: clamp(22px, 4vw, 48px); box-shadow: var(--shadow); margin: 0 auto; line-height: 1.6; }
.prose h2 { margin-top: 1.6em; }
.prose a { color: var(--accent); }

/* ---------- Pie ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 36px 0 calc(36px + env(safe-area-inset-bottom)); font-size: 0.95rem; }
.footer-grid { display: grid; gap: 28px 48px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .footer-grid { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); } }
.subscribe { display: flex; gap: 10px; flex-wrap: wrap; max-width: 460px; }
.subscribe input[type="email"] { flex: 1 1 200px; border-radius: 999px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 8px 22px; align-content: flex-start; }
.footer-links a { min-height: 44px; display: inline-flex; align-items: center; }
.copyright { margin-top: 28px; color: var(--ink-2); font-size: 0.85rem; }

/* ---------- Pantallas pequeñas ---------- */
@media (max-width: 880px) {
  .hero { grid-template-columns: minmax(0, 1fr); }
  .hero-text p { max-width: 46ch; }
  /* Cabecera compacta: marca y acciones arriba, luego menú y buscador. No se queda pegada. */
  .site-header { position: static; }
  .header-row { row-gap: 4px; }
  .brand { order: 1; }
  .header-spacer { display: none; }
  .header-actions { order: 2; margin-left: auto; }
  .main-nav { order: 3; flex: 1 1 100%; gap: 4px 22px; }
  .search { order: 4; flex: 1 1 100%; padding-bottom: 4px; }
  .search input { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

@media print {
  .site-header, .site-footer, .like-form, .placard-actions { display: none; }
  body { background: #fff; color: #000; }
}
