/* Phone layouts keep the same photographs and controls, with room to read and tap. */
@media (max-width: 680px) {
  html { -webkit-text-size-adjust: 100%; }
  .site-header { padding-inline: max(5%, env(safe-area-inset-left)); }
  .site-header, main, footer, .intro-heading > *, .section-heading > * { min-width: 0; }
  .header-actions { min-width: 0; gap: 8px; }
  #menu-button, .photo-search-button, .owner-activity-button { min-width: 44px; min-height: 44px; }
  .language-switch select { min-height: 44px; font-size: 16px; width: 116px; }
  .site-header nav { max-height: calc(100dvh - 110px); overflow-y: auto; overscroll-behavior: contain; }
  .site-header nav a { min-height: 48px; overflow-wrap: anywhere; }
  .intro-heading h1 { max-width: 100%; overflow-wrap: normal; }
  .intro-copy p, .section-heading > p { font-size: 13px; line-height: 1.75; }
  .hero { height: clamp(280px, 105vw, 430px); max-height: 65svh; min-height: 240px; }
  .hero-caption { left: 17px; right: 17px; bottom: 22px; }
  .hero-caption p { overflow-wrap: anywhere; }
  .hero-footnote #hero-photo-label { font-size: 10px; letter-spacing: .3px; }
  .hero-browse-tools { gap: 16px; }
  .hero-browse-tools .month-navigation-label, .slideshow-speed label { font-size: 10px; }
  .gallery-toolbar { margin-bottom: 22px; }
  .filter { min-height: 44px; font-size: 12px; padding: 10px 11px; }
  .filter span { font-size: 10px; }
  .featured-refresh, .featured-refresh .plain-button, .collection-order-note { font-size: 12px; }
  .featured-refresh .plain-button { min-height: 44px; white-space: normal; text-align: left; }
  .photo-like-button, .photo-comment-button { min-height: 44px; font-size: 12px; }
  .favorite-toggle { width: 44px; height: 44px; }
  .gallery .photo-category { font-size: 10px; letter-spacing: .45px; }
  .gallery .photo-title { font-size: 21px; }
  .gallery-actions .outline-button, .plain-button, .text-link, .outline-button { min-height: 44px; }
  .contact-secondary { align-items: flex-start; flex-direction: column; gap: 14px; font-size: 12px; }
  .contact-secondary > a { align-items: flex-start; gap: 5px; }
  .contact-secondary > a > span { font-size: 12px; }
  .email-actions { gap: 8px 20px; }
  .email-actions a, .email-actions button, .contact-secondary > a, .contact-topics a { min-height: 44px; display: inline-flex; align-items: center; }
  .contact-email { font-size: clamp(17px, 4.8vw, 24px); line-height: 1.5; }
  .contact-topics { font-size: 12px; gap: 4px 20px; }
  .footer-bottom { flex-wrap: wrap; font-size: 10px; line-height: 1.7; }
  .footer-bottom a { min-height: 44px; display: inline-flex; align-items: center; }
  .prints-field select, .prints-field input, .prints-field textarea { font-size: 16px; }
  .prints-view, .prints-choose, .prints-gmail, .prints-footer a { min-height: 44px; }

  #lightbox { height: 100dvh; max-height: 100dvh; }
  .lightbox-shell { padding: env(safe-area-inset-top) max(12px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(12px, env(safe-area-inset-left)); overflow-y: auto; overscroll-behavior: contain; }
  .lightbox-header { height: 60px; min-height: 60px; gap: 10px; }
  .lightbox-brand { min-width: 0; font-size: 10px; line-height: 1.5; overflow-wrap: anywhere; }
  .lightbox-header-actions { flex: 0 0 auto; gap: 8px; }
  .lightbox-header .close { width: 44px; height: 44px; }
  .lightbox-stage { min-height: 180px; }
  .lightbox-stage .icon-button { width: 44px; height: 44px; bottom: 10px; }
  .viewer-filmstrip { flex-shrink: 0; margin-inline: 0; }
  .lightbox-footer { flex: 0 0 auto; display: flex; flex-direction: column; align-items: stretch; gap: 12px; padding: 12px 0 16px; }
  .lightbox-footer > div:first-child, .comments-open .lightbox-footer > div:first-child { max-width: 100%; }
  .lightbox-footer h2 { font-size: 22px; overflow-wrap: anywhere; }
  .lightbox-footer p { font-size: 10px; line-height: 1.6; }
  .lightbox-bottom-right, .comments-open .lightbox-bottom-right { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; gap: 10px; width: 100%; max-width: 100%; align-items: center; white-space: normal; }
  #lightbox-count { grid-column: 1 / -1; grid-row: 1; text-align: center; font-size: 11px; }
  .lightbox-social { grid-column: 2; grid-row: 2; justify-self: center; gap: 8px; }
  .lightbox-reactions { gap: 10px; }
  .lightbox-social .lightbox-playback { width: 44px; height: 44px; }
  .lightbox-bottom-right .favorite-photo { grid-column: 1; grid-row: 2; width: 44px; height: 44px; }
  .fullscreen-button { grid-column: 3; grid-row: 2; width: 44px; height: 44px; padding: 0; display: grid; place-items: center; }
  #fullscreen-label { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
  .fullscreen-button > span:last-child { font-size: 24px; padding: 0; }
  .photo-inquiry { grid-column: 1 / -1; grid-row: 3; min-height: 44px; display: flex; align-items: center; justify-content: center; font-size: 12px; white-space: normal; text-align: center; line-height: 1.6; padding: 6px 12px; }
  .comments-open > .lightbox-stage { min-height: 220px; height: 45svh; }
  .comments-open > .lightbox-header { min-height: 60px; }
  .comments-open > .lightbox-footer { flex-direction: column; flex-wrap: nowrap; align-items: stretch; }
  .comments-open .lightbox-footer > div:first-child { flex-basis: auto; }
  .photo-comments-panel { padding-bottom: max(28px, env(safe-area-inset-bottom)); }
  .photo-comments-form input, .photo-comments-form textarea { font-size: 16px; }
  .photo-comments-close, .photo-comments-submit, .photo-comments-more, .photo-comment-delete, .photo-comment-cancel { min-height: 44px; }
  .photo-comments-close { width: 44px; flex-basis: 44px; }
  dialog:is(#photo-search, #moderator-menu, #owner-activity) { width: calc(100% - 16px); max-height: calc(100dvh - 16px); height: calc(100dvh - 16px); }
  .search-close, .moderation-close, .activity-close { width: 44px; height: 44px; flex-basis: 44px; }
  .search-clear, .search-suggestion, .activity-tab, .activity-refresh, .moderation-toolbar button, .moderation-row-actions button, .activity-open-photo { min-height: 44px; }
  .moderation-toolbar { flex-wrap: wrap; }
  .search-input { font-size: 16px; }
  .search-header h2, .moderation-header h2, .activity-header h2 { overflow-wrap: anywhere; }
  .search-content, .moderation-content, .activity-content { padding-bottom: max(24px, env(safe-area-inset-bottom)); }
}

@media (max-width: 480px) {
  .site-header { height: auto; min-height: 122px; flex-wrap: wrap; gap: 12px; padding-top: max(12px, env(safe-area-inset-top)); padding-bottom: 12px; }
  .brand { flex-basis: 100%; gap: 12px; }
  body .site-header:has(#photo-search-button) .brand-name { display: block; font-size: 11px; }
  .brand-name > span { font-size: 7px; }
  .header-actions, .site-header:has(#photo-search-button) .header-actions { width: 100%; margin: 0; gap: 8px; }
  .header-actions > .language-switch { flex: 1 1 0; min-width: 0; }
  .site-header .language-switch select, .site-header:has(#photo-search-button) .language-switch select { width: 100%; min-width: 0; }
  #menu-button { width: 44px; flex: 0 0 44px; }
  .site-header nav { padding-inline: 5%; max-height: calc(100dvh - 126px); }
  .intro { padding-top: 26px; }
  .intro-heading { gap: 20px; }
  .intro-heading h1 { font-size: clamp(44px, 15vw, 70px); letter-spacing: -2.5px; line-height: 1.12; }
  html[lang=en] .intro-heading h1 { font-size: clamp(43px, 14vw, 67px); }
  .hero-controls { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: center; gap: 8px 6px; }
  .hero-scroll-hint { display: none; }
  #hero-count { grid-column: 1 / -1; grid-row: 1; font-size: 11px; }
  #hero-like { grid-column: 1; grid-row: 2; }
  #hero-comments { grid-column: 2; grid-row: 2; }
  #hero-playback { grid-column: 3; grid-row: 2; }
  #hero-previous { grid-column: 4; grid-row: 2; }
  #hero-next { grid-column: 5; grid-row: 2; }
  .hero-controls .hero-control { width: 44px; min-width: 44px; max-width: 100%; justify-self: center; }
  #hero-like, #hero-comments { display: flex; min-width: 0; }
  .hero-controls .photo-like-button, .hero-controls .photo-comment-button { min-width: 0; width: 100%; min-height: 44px; padding: 6px; gap: 4px; }
  .gallery { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .gallery .photo-title { font-size: 24px; }
  .photo-actions { gap: 10px; }
  .gallery .photo-category { font-size: 11px; }
  .filters { gap: 6px; }
  .filter { padding-inline: 10px; }
  .section-heading h2 { font-size: clamp(34px, 10vw, 42px); overflow-wrap: anywhere; }
  .explore-grid { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .explore-card, .explore-card:first-child, .explore-card:nth-child(-n+2) { grid-column: auto; }
  .explore-card-heading h3 { font-size: 30px; }
  .explore-card > p { font-size: 12px; }
  .contact-section { padding-inline: 6%; }
}

/* Short, wide screens: photos get the space and every control remains reachable. */
@media (orientation: landscape) and (max-height: 500px) and (max-width: 1100px) {
  html { -webkit-text-size-adjust: 100%; scroll-padding-top: 16px; }
  .site-header, main, footer, .intro-heading > *, .section-heading > * { min-width: 0; }
  .site-header { height: 68px; min-height: 68px; gap: 16px; padding: 8px max(24px, env(safe-area-inset-right)) 8px max(24px, env(safe-area-inset-left)); }
  .brand { flex-basis: auto; gap: 12px; }
  .brand-mark { font-size: 39px; }
  body .site-header:has(#photo-search-button) .brand-name { display: block; font-size: 10px; }
  .brand-name > span { font-size: 7px; }
  .header-actions, .site-header:has(#photo-search-button) .header-actions { width: auto; min-width: 0; gap: 8px; margin-left: auto; }
  #menu-button, .photo-search-button, .owner-activity-button { min-width: 44px; min-height: 44px; }
  .language-switch select { width: 132px; min-height: 44px; font-size: 16px; }
  .site-header nav { padding: 8px max(24px, env(safe-area-inset-right)) 12px max(24px, env(safe-area-inset-left)); max-height: calc(100dvh - 68px - env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain; }
  .site-header nav.is-open { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px; align-content: start; }
  .site-header nav a { min-height: 44px; padding: 12px 0; overflow-wrap: anywhere; }
  .intro { padding: 22px max(24px, env(safe-area-inset-right)) 0 max(24px, env(safe-area-inset-left)); }
  .intro-heading { display: grid; grid-template-columns: minmax(0, 1fr) minmax(185px, 29%); gap: 24px; margin: 12px 0 24px; align-items: center; }
  .intro-heading h1, html[lang=en] .intro-heading h1, html:not([lang=is]):not([lang=en]) .intro-heading h1 { max-width: 100%; font-size: clamp(40px, 7.2vw, 76px); letter-spacing: -.045em; line-height: 1.08; white-space: normal; overflow-wrap: anywhere; }
  .intro-copy { display: block; width: auto; padding: 0; }
  .intro-copy p { font-size: 12px; line-height: 1.6; }
  .intro-copy .text-link { min-width: 0; min-height: 44px; margin-top: 8px; gap: 18px; padding: 8px 0; }
  .hero-carousel { padding: 12px; }
  .hero { height: clamp(180px, calc(100svh - 110px), 340px); min-height: 180px; max-height: none; }
  .hero-slide { flex-basis: calc(100% - 40px); }
  .hero-caption { bottom: 20px; left: 22px; right: 22px; }
  .hero-caption p { max-width: none; font-size: 26px; overflow-wrap: anywhere; }
  .hero-arrow { flex-shrink: 0; width: 44px; height: 44px; }
  .hero-footnote { gap: 10px 20px; }
  #hero-photo-label { font-size: 11px; letter-spacing: .2px; }
  .hero-controls { width: auto; justify-content: flex-end; gap: 8px; }
  .hero-scroll-hint { display: none; }
  .hero-control, .photo-like-button, .photo-comment-button { min-height: 44px; }
  .hero-browse-tools { margin-top: 14px; padding-top: 14px; gap: 14px 24px; align-items: center; }
  .hero-browse-tools > .month-navigation { flex-direction: row; align-items: center; width: auto; gap: 8px 12px; }
  .month-navigation-select { width: 225px; min-height: 44px; font-size: 16px; }
  .slideshow-speed select { min-height: 44px; font-size: 16px; }
  .slideshow-speed--viewer label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
  .collection { padding: 50px max(24px, env(safe-area-inset-right)) 0 max(24px, env(safe-area-inset-left)); }
  body:is([data-page=archive],[data-page=favorites]) #safn, body[data-page=series] #myndaradir { padding-top: 34px; }
  .section-heading { display: flex; align-items: flex-end; gap: 24px; }
  .section-heading h2 { font-size: 40px; }
  .section-heading > p { max-width: 42%; font-size: 12px; line-height: 1.65; }
  .filter { min-height: 44px; font-size: 11px; }
  .filters { gap: 5px; }
  .gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 30px 20px; }
  .gallery .photo-title { font-size: 22px; }
  .gallery .photo-category { font-size: 10px; white-space: normal; }
  .photo-actions { flex-wrap: wrap; }
  .favorite-toggle { width: 44px; height: 44px; }
  .series-section, .explore-section { padding: 45px max(24px, env(safe-area-inset-right)) 40px max(24px, env(safe-area-inset-left)); }
  .series-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 30px 24px; }
  .explore-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .explore-card, .explore-card:first-child, .explore-card:nth-child(-n+2) { grid-column: auto; }
  .about { grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); gap: 30px; padding: 36px max(24px, env(safe-area-inset-right)) 36px max(24px, env(safe-area-inset-left)); }
  .about-image img { max-height: 75svh; object-fit: contain; }
  .about-copy h2 { font-size: 38px; margin-bottom: 18px; }
  .contact-section { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 30px; padding: 40px max(24px, env(safe-area-inset-right)) 40px max(24px, env(safe-area-inset-left)); }
  .contact-section h2 { font-size: 40px; }
  .contact-email { font-size: clamp(17px, 2.7vw, 26px); overflow-wrap: anywhere; }
  .contact-secondary { flex-wrap: wrap; gap: 10px; }
  .email-actions a, .email-actions button, .contact-secondary > a, .contact-topics a { display: inline-flex; align-items: center; min-height: 44px; }
  .prints-section { padding: 36px max(24px, env(safe-area-inset-right)) 40px max(24px, env(safe-area-inset-left)); }
  .prints-header { margin-bottom: 42px; }
  .prints-header h1 { font-size: clamp(40px, 6vw, 64px); white-space: normal; }
  .prints-intro { font-size: 15px; }
  .prints-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .prints-enquiry-layout { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px; }
  .prints-field select, .prints-field input, .prints-field textarea { font-size: 16px; }
  .prints-view, .prints-choose, .prints-gmail { min-height: 44px; }
  footer { padding: 40px max(24px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left)); }
  .footer-name { font-size: 48px; }
  .footer-bottom { flex-wrap: wrap; }
  .footer-bottom a { display: inline-flex; align-items: center; min-height: 44px; }

  #lightbox { width: 100%; height: 100dvh; max-height: 100dvh; }
  .lightbox-shell:not(.comments-open) { display: grid; grid-template-columns: minmax(0, 1fr) clamp(210px, 29vw, 290px); grid-template-rows: 48px minmax(0, 1fr) 58px; gap: 0 18px; height: 100%; padding: max(4px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(4px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); overflow: auto; }
  .lightbox-shell:not(.comments-open) > .lightbox-header { grid-column: 1 / -1; grid-row: 1; height: 48px; min-height: 48px; gap: 12px; }
  .lightbox-brand { min-width: 0; font-size: 10px; line-height: 1.4; overflow-wrap: anywhere; }
  .lightbox-header-actions { flex-shrink: 0; gap: 8px; }
  .lightbox-header .close { width: 44px; height: 44px; }
  .lightbox-shell:not(.comments-open) > .lightbox-stage { grid-column: 1; grid-row: 2; min-height: 0; min-width: 0; }
  .lightbox-shell:not(.comments-open) > .viewer-filmstrip { grid-column: 1; grid-row: 3; width: 100%; height: 58px; max-height: 58px; margin: 0; padding: 6px 3px; gap: 6px; }
  .viewer-thumb { flex-basis: 54px; width: 54px; height: 44px; }
  .lightbox-shell:not(.comments-open) > .lightbox-footer { grid-column: 2; grid-row: 2 / 4; min-width: 0; min-height: 0; max-height: 100%; display: flex; flex-direction: column; justify-content: center; align-items: stretch; padding: 6px 0; gap: 10px; overflow-y: auto; overscroll-behavior: contain; }
  .lightbox-footer > div:first-child { max-width: 100%; }
  .lightbox-footer h2 { font-size: clamp(18px, 2.4vw, 23px); overflow-wrap: anywhere; }
  .lightbox-footer p { font-size: 10px; line-height: 1.5; }
  .lightbox-bottom-right, .comments-open .lightbox-bottom-right { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; gap: 8px; width: 100%; min-width: 0; max-width: 100%; white-space: normal; align-items: center; }
  #lightbox-count { grid-column: 1 / -1; grid-row: 1; text-align: center; }
  .lightbox-social { grid-column: 2; grid-row: 2; justify-self: center; gap: 6px; }
  .lightbox-reactions { gap: 8px; }
  .lightbox-social .lightbox-playback { width: 44px; height: 44px; }
  .lightbox-bottom-right .favorite-photo { grid-column: 1; grid-row: 2; width: 44px; height: 44px; }
  .fullscreen-button { grid-column: 3; grid-row: 2; width: 44px; height: 44px; padding: 0; display: grid; place-items: center; }
  #fullscreen-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
  .fullscreen-button > span:last-child { font-size: 24px; padding: 0; }
  .photo-inquiry { grid-column: 1 / -1; grid-row: 3; min-height: 44px; display: flex; align-items: center; justify-content: center; font-size: 11px; line-height: 1.5; white-space: normal; text-align: center; padding: 6px; }
  .lightbox-stage > img { width: 100%; height: 100%; object-fit: contain; }
  .lightbox-stage .icon-button { position: absolute; bottom: 8px; width: 44px; height: 44px; }
  .lightbox-stage .previous { left: 5px; }
  .lightbox-stage .next { right: 5px; }
  .lightbox-shell.comments-open { display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, 36%); grid-template-rows: 48px minmax(120px, 1fr) auto; gap: 0 20px; height: 100%; padding: max(4px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(4px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); overflow: auto; }
  .comments-open > .lightbox-header { position: static; grid-column: 1 / -1; grid-row: 1; height: 48px; min-height: 48px; }
  .comments-open > .lightbox-stage { grid-column: 1; grid-row: 2; width: 100%; min-width: 0; min-height: 120px; height: auto; }
  .comments-open > .lightbox-stage > img { width: 100%; }
  .comments-open > .lightbox-footer { grid-column: 1; grid-row: 3; display: flex; flex-direction: column; align-items: stretch; flex-wrap: nowrap; min-height: 0; max-height: 40dvh; overflow-y: auto; padding: 8px 0; }
  .comments-open .lightbox-footer > div:first-child { flex-basis: auto; }
  .comments-open > .photo-comments-panel { grid-column: 2; grid-row: 2 / 4; max-height: 100%; min-height: 0; overflow-y: auto; padding: 0 0 16px 18px; border-top: 0; border-left: 1px solid #5b4c3e; }
  .photo-comments-heading h2 { font-size: 25px; }
  .photo-comments-close { flex-basis: 44px; width: 44px; height: 44px; }
  .photo-comments-form input, .photo-comments-form textarea { font-size: 16px; }
  .photo-comments-form textarea { min-height: 80px; }
  .photo-comments-submit, .photo-comments-more { min-height: 44px; }
  dialog:is(#photo-search,#moderator-menu,#owner-activity) { width: calc(100% - max(16px, env(safe-area-inset-left)) - max(16px, env(safe-area-inset-right))); height: calc(100dvh - 16px); max-height: calc(100dvh - 16px); }
  .search-close, .moderation-close, .activity-close { width: 44px; height: 44px; flex-basis: 44px; }
  .search-input { font-size: 16px; }
  .moderation-toolbar { flex-wrap: wrap; }
}
@media (orientation: landscape) and (max-height: 500px) and (max-width: 740px) {
  .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero-controls { gap: 6px; }
  .hero-browse-tools { align-items: stretch; }
  .hero-browse-tools > .month-navigation { flex: 1 1 260px; }
  .hero-browse-tools > .slideshow-speed { margin-left: auto; }
  .section-heading { align-items: flex-start; }
  .section-heading > p { max-width: 45%; }
}
