/* Art is the content: quiet, evenly spaced tiles without article furniture. */
.maddagu-gallery-page .tpl-intro { padding: 0; }
.maddagu-gallery-page .tpl-intro h1 { margin-bottom: 12px; }
.maddagu-gallery-page .maddagu-gallery-intro { margin-bottom: 28px; }
#maddagu-gallery-images { scroll-margin-top: 32px; }
.maddagu-gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  margin-block: 0 58px;
}
.maddagu-gallery-tile { min-width: 0; margin: 0; }
.maddagu-gallery-link {
  display: block;
  aspect-ratio: 1;
  background: var(--surface);
  overflow: hidden;
  cursor: zoom-in;
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.maddagu-gallery-link img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: none;
  transition: transform .4s;
}
.maddagu-gallery-link:hover img { transform: scale(1.025); }
.maddagu-gallery-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 5px; }
.maddagu-gallery-pagination { display: flex; flex-wrap: wrap; align-items: center; gap: 24px; padding-block: 20px; color: var(--accent); font-size: 12px; }
.maddagu-gallery-pagination a { display: inline-flex; align-items: center; min-height: 44px; padding-block: 10px; }
.maddagu-gallery-pagination a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 5px; }

/* Native dialog supplies a focus boundary and an inert background. */
.maddagu-gallery-viewer {
  width: min(1440px, calc(100% - 56px));
  max-width: none;
  height: min(900px, calc(100vh - 56px));
  height: min(900px, calc(100dvh - 56px));
  max-height: none;
  margin: auto;
  padding: 20px 24px 24px;
  border: 0;
  border-radius: 20px;
  box-shadow: 0 20px 80px #0003;
  background: var(--card);
  color: var(--ink);
  overflow: hidden;
}
.maddagu-gallery-viewer:not([open]) { display: none; }
.maddagu-gallery-viewer[open] { display: flex; flex-direction: column; gap: 16px; }
.maddagu-gallery-viewer::backdrop { background: #0009; backdrop-filter: blur(12px); }
.maddagu-gallery-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex: 0 0 auto; }
.maddagu-gallery-toolbar [data-gallery-counter] { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.maddagu-gallery-viewer button { flex: 0 0 auto; min-width: 44px; min-height: 44px; padding: 9px 13px; border: 0; border-radius: 24px; background: var(--page); color: var(--ink); }
.maddagu-gallery-viewer button:hover { background: var(--surface); }
.maddagu-gallery-viewer button:focus-visible { outline-offset: 3px; }
.maddagu-gallery-viewer [data-gallery-close] { font-size: 12px; }
.maddagu-gallery-stage { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; align-items: center; gap: 20px; min-height: 0; flex: 1 1 auto; position: relative; }
.maddagu-gallery-stage.is-single { grid-template-columns: minmax(0, 1fr); }
.maddagu-gallery-stage > figure { display: flex; flex-direction: column; align-items: center; width: 100%; height: 100%; min-height: 0; margin: 0; gap: 16px; }
.maddagu-gallery-stage [data-gallery-full] { display: block; width: 100%; height: 0; min-height: 0; flex: 1 1 auto; object-fit: contain; filter: none; border-radius: 12px; }
.maddagu-gallery-stage [data-gallery-full][hidden] { visibility: hidden; }
.maddagu-gallery-stage [data-gallery-caption] { flex: 0 0 auto; width: min(100%, 760px); max-height: 20%; overflow-y: auto; overflow-wrap: anywhere; color: var(--muted); font-size: 12px; line-height: 1.7; text-align: center; }
.maddagu-gallery-stage [data-gallery-caption]:empty { display: none; }
.maddagu-gallery-stage [data-gallery-prev], .maddagu-gallery-stage [data-gallery-next] { font-size: 20px; padding: 4px; }
.maddagu-gallery-stage button[hidden] { display: none; }
.maddagu-gallery-status { position: absolute; inset: 50% 64px auto; transform: translateY(-50%); margin: 0; padding: 18px; color: var(--muted); background: var(--paper); text-align: center; font-size: 13px; }
.maddagu-gallery-status[hidden] { display: none; }
.maddagu-gallery-status a { display: inline-block; margin-top: 12px; color: var(--accent); text-decoration: underline; text-underline-offset: 4px; }
@media (max-width: 900px) {
  .maddagu-gallery-grid { gap: 16px; }
  .maddagu-gallery-viewer { padding: 16px; width: calc(100% - 32px); height: calc(100vh - 32px); height: calc(100dvh - 32px); }
  .maddagu-gallery-stage { gap: 12px; }
}
@media (max-width: 650px) {
  .maddagu-gallery-page .tpl-intro { padding: 0; }
  .maddagu-gallery-page .maddagu-gallery-intro { margin-bottom: 24px; }
  .maddagu-gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 36px; }
  .maddagu-gallery-link { border-radius: 12px; }
  .maddagu-gallery-viewer { width: 100%; height: 100vh; height: 100dvh; border: 0; border-radius: 0; padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
  .maddagu-gallery-stage { grid-template-columns: 1fr 1fr; grid-template-rows: minmax(0, 1fr) 44px; gap: 16px; }
  .maddagu-gallery-stage > figure { grid-column: 1 / -1; grid-row: 1; }
  .maddagu-gallery-stage [data-gallery-prev] { grid-column: 1; grid-row: 2; justify-self: end; min-width: 64px; }
  .maddagu-gallery-stage [data-gallery-next] { grid-column: 2; grid-row: 2; justify-self: start; min-width: 64px; }
  .maddagu-gallery-stage.is-single { grid-template-rows: minmax(0, 1fr); }
  .maddagu-gallery-stage [data-gallery-caption] { font-size: 11px; max-height: 24%; }
  .maddagu-gallery-status { inset-inline: 0; }
}
@media (max-width: 359px) { .maddagu-gallery-grid { grid-template-columns: minmax(0, 1fr); } }
