/* Loaded after the existing theme: responsive layout, media and interaction fixes. */
html { scroll-padding-top: 100px; }
body { min-width: 0; }
*, *::before, *::after { box-sizing: border-box; }
.wrap { max-width: 1200px; width: min(1200px, calc(100% - 48px)); margin-inline: auto; }
main, main section, .section-heading, .project-card, .slide-copy { min-width: 0; }
.site-header { position: sticky; top: 0; z-index: 100; background: rgb(255 249 251 / .96); backdrop-filter: blur(14px); }
.site-header .nav { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 84px; }
.site-header .brand { flex-shrink: 0; white-space: nowrap; }
.site-header .nav-links { display: flex; align-items: center; gap: clamp(12px, 1.6vw, 26px); }
.site-header .nav-links a { padding-block: 12px; }
.site-header .menu-toggle, .site-header .mobile-contact { display: none; }
.site-header .nav-cta { flex-shrink: 0; }
button, .button, .nav-links a, .project-link { transition: transform .2s ease, background-color .2s ease, color .2s ease, box-shadow .2s ease; }
button:active:not(:disabled), .button:active { transform: scale(.97); }
.button, .carousel-arrow, .gallery-arrow, .gallery-expand { min-height: 44px; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tags span { max-width: 100%; overflow-wrap: anywhere; }

/* Content photos use landscape frames. Hero/About profile cards keep the original portrait layout; logos and icons keep their shapes. */
.restored-project-photo, .restored-showcase-photo, .banner-frame, .embed-shell, .personal-gallery .personal-image-frame, .react-gallery-stage.fit-cover, .react-gallery-stage.fit-contain, .collection-photo, .certificate-preview-trigger { aspect-ratio: 16 / 9; height: auto; min-height: 0; overflow: hidden; }
.restored-project-photo > img, .restored-showcase-photo > img, .banner-frame > img, .personal-gallery .personal-image-frame > img, .react-gallery-stage > img, .collection-photo > img, .certificate-preview-trigger > img { display: block; width: 100%; height: 100%; aspect-ratio: 16 / 9; object-fit: cover; object-position: center; margin: 0; }
.certificate-preview-trigger > img { object-fit: contain; background: #fff; }
.embed-shell, .banner-frame { width: 100%; position: relative; }
.activity-frame { min-width: 0; height: auto; }
.personal-gallery .personal-slide { margin: 0; }
.react-gallery-stage { padding: 0; border: 0; }
.react-gallery-stage.fit-contain > img { object-fit: contain; }
.gallery-stage { position: relative; height: auto; min-height: 0; padding: 0; aspect-ratio: auto; overflow: hidden; touch-action: pan-y; }
.gallery-slide { margin: 0; display: block; }
.gallery-slide > img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; }
.gallery-slide figcaption { position: static; padding: 16px 20px; background: #fff7fa; color: #59414e; }
.gallery-thumbnails, .react-gallery-thumbs, .personal-thumbs { display: flex; max-width: 100%; overflow-x: auto; gap: 10px; padding-block: 8px; }
.gallery-thumbnails > button, .react-gallery-thumbs > button, .personal-thumbs > button { width: 112px; flex: 0 0 112px; min-width: 0; }
.gallery-thumbnails img, .react-gallery-thumbs img, .personal-gallery .personal-thumbs img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; }
.gallery-thumbnails span { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* Fixed stage height is measured by the component from the tallest slide. */
.project-showcase { width: 100%; max-width: 100%; overflow: hidden; padding-block: 10px; }
.showcase-toolbar { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding-block: 16px; }
.showcase-toolbar > * { min-width: 0; overflow-wrap: anywhere; }
.project-showcase .showcase-stage { position: relative; width: 100%; height: var(--showcase-height, 650px); min-height: 0; perspective: 1400px; overflow: hidden; touch-action: pan-y; transition: height .3s ease; }
.project-showcase .showcase-slide { position: absolute; top: 16px; left: 50%; width: min(64%, 620px); height: auto; max-width: none; margin: 0; border: 1px solid #efd0dd; border-radius: 24px; background: #fff; overflow: hidden; box-shadow: 0 12px 36px #893b5a14; transform-origin: center; transition: transform .55s cubic-bezier(.22,.7,.25,1), opacity .4s ease; }
.project-showcase .slide-art { position: relative; padding: 0; width: 100%; height: auto; aspect-ratio: 16 / 9; overflow: hidden; }
.project-showcase .restored-showcase-photo { width: 100%; height: 100%; }
.project-showcase .slide-art img { width: 100%; height: 100%; object-fit: cover; }
.project-showcase .slide-select { position: absolute; inset: 0; width: 100%; height: 100%; background: transparent; border: 0; cursor: pointer; }
.project-showcase .preview-label { position: absolute; left: 16px; bottom: 16px; border-radius: 30px; padding: 6px 12px; background: #fff3f7ed; color: #8f3157; font-size: 11px; }
.project-showcase .slide-copy { padding: 24px; }
.project-showcase .slide-copy h3 { margin: 8px 0 12px; font-size: clamp(24px, 3vw, 32px); overflow-wrap: anywhere; }
.project-showcase .slide-copy p { font-size: 16px; line-height: 1.7; margin-bottom: 16px; }
.project-showcase .slide-copy .tags { margin-bottom: 18px; }
.project-showcase .project-link { display: inline-flex; align-items: center; min-height: 44px; gap: 18px; }
.showcase-controls { display: flex; justify-content: center; align-items: center; gap: 18px; padding: 12px 0; }
.carousel-dots { display: flex; flex-wrap: wrap; justify-content: center; max-width: 65%; }
.carousel-dots button { display: grid; place-items: center; width: 30px; height: 44px; border: 0; background: transparent; }
.carousel-dots button span { width: 8px; height: 8px; border-radius: 50%; background: #e4b8c9; transition: width .25s ease; }
.carousel-dots button[aria-pressed=true] span { width: 20px; border-radius: 10px; background: #cf416e; }
.showcase-hint { text-align: center; font-size: 14px; }

/* Tailwind's reset removes the browser dialog margins; explicitly restore centering. */
dialog.portfolio-modal, dialog.image-lightbox, dialog.certificate-dialog, .media-picker dialog {
  position: fixed; inset: 0; margin: auto !important; float: none;
  width: min(1120px, calc(100vw - 32px)); max-width: calc(100vw - 32px);
  height: fit-content; max-height: calc(100dvh - 32px); overflow: auto;
  padding: 24px; border: 1px solid #efd0dd; border-radius: 22px;
  background: #fff9fb; color: #342c32; box-shadow: 0 24px 100px #29111d40;
}
dialog:not([open]) { display: none; }
dialog[open] { animation: modal-arrive .22s ease both; }
dialog::backdrop { background: #29111db3; backdrop-filter: blur(6px); }
body:has(dialog[open]) { overflow: hidden; }
.lightbox-toolbar, .certificate-dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.lightbox-toolbar button, .certificate-dialog-close { min-height: 44px; flex-shrink: 0; padding: 8px 14px; border-radius: 30px; border: 1px solid #e4b8c9; }
.lightbox-image-wrap, .certificate-dialog-image-wrap { position: relative; display: flex; align-items: center; justify-content: center; width: 100%; aspect-ratio: 16 / 9; background: #fceff4; border-radius: 12px; overflow: hidden; }
.lightbox-image-wrap > img, .certificate-dialog-image-wrap > .certificate-dialog-image { display: block; width: 100%; height: 100%; max-height: none; object-fit: contain; aspect-ratio: 16 / 9; }
.lightbox-image-wrap > button, .certificate-dialog-image-wrap > button { position: absolute; top: 50%; transform: translateY(-50%); z-index: 1; width: 44px; height: 44px; border-radius: 50%; background: #fff9; color: #8f3157; }
.lightbox-image-wrap > button:first-child, .certificate-dialog-prev { left: 8px; }
.lightbox-image-wrap > button:last-child, .certificate-dialog-next { right: 8px; }
.lightbox-caption, .image-lightbox > p { margin-top: 14px; overflow-wrap: anywhere; }
.certificate-dialog-header h2 { font-size: clamp(20px, 4vw, 28px); }

.sortable-image-list { display: grid; gap: 16px; }
.sortable-image-row { border: 1px solid #edd0dc; border-radius: 14px; padding: 12px; background: #fff; transition: background-color .18s, box-shadow .18s; }
.sortable-image-row.is-dragging { background: #fff0f5; box-shadow: 0 0 0 2px #cf416e; }
.sortable-image-row.is-drop-target { box-shadow: 0 -4px 0 #cf416e; background: #fff5f8; }
.sort-row-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; font-size: 14px; color: #7b435b; }
.sort-handle { touch-action: none; user-select: none; min-height: 44px; padding: 8px 14px; border: 1px solid #e4b8c9; border-radius: 10px; cursor: grab; }
.sort-handle:active { cursor: grabbing; }
.sort-help { font-size: 14px; line-height: 1.7; margin-bottom: 16px; color: #715765; }
.admin-screenshot { min-width: 0; }
.admin-screenshot > div, .media-selection > * { min-width: 0; }
.admin-screenshot img { width: 130px; height: auto; aspect-ratio: 16 / 9; object-fit: cover; }
.media-option img, .media-selection img { height: auto; aspect-ratio: 16 / 9; object-fit: cover; }
.media-selection { flex-wrap: wrap; }
.admin-main input, .admin-main textarea, .admin-main select { min-width: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.motion-reveal { transition: opacity .6s ease, translate .6s cubic-bezier(.2,.7,.3,1); }
.reveal-waiting { opacity: 0; translate: 0 20px; }
@keyframes modal-arrive { from { opacity: 0; translate: 0 10px; } to { opacity: 1; translate: 0 0; } }
@keyframes photo-arrive { from { opacity: .4; } to { opacity: 1; } }
.gallery-slide > img, .personal-image-frame > img, .react-gallery-stage > img { animation: photo-arrive .3s ease; }
@media (hover: hover) and (pointer: fine) {
  .button:hover { translate: 0 -2px; box-shadow: 0 8px 20px #a23d601f; }
  .project-photo-link img { transition: transform .45s ease; }
  .project-photo-link:hover img { transform: scale(1.035); }
  .nav-links a:hover { color: #bd315f; }
}
@media (max-width: 1024px) {
  .site-header .nav { min-height: 72px; }
  .site-header .menu-toggle { display: inline-flex; align-items: center; gap: 12px; margin-left: auto; min-height: 44px; padding: 8px 14px; border: 1px solid #e4b8c9; border-radius: 12px; background: #fff7fa; color: #84324f; }
  .site-header .nav-cta { display: none; }
  .site-header .nav-links { display: none; position: absolute; inset: 100% 0 auto; max-height: calc(100dvh - 90px); overflow-y: auto; padding: 12px; border: 1px solid #efd0dd; border-radius: 0 0 18px 18px; background: #fff9fb; box-shadow: 0 16px 32px #893b5a1a; }
  .site-header .nav-links.is-open { display: grid; grid-template-columns: 1fr; gap: 4px; animation: modal-arrive .2s ease; }
  .site-header .nav-links a { display: block; padding: 12px 14px; min-height: 44px; border-radius: 10px; }
  .site-header .mobile-contact { display: block; color: #bd315f; background: #ffedf3; }
}
@media (max-width: 760px) {
  .wrap { width: calc(100% - 32px); }
  .section { padding-block: 56px; }
  .section-heading { flex-wrap: wrap; gap: 16px; }
  .hero, .hero-grid, .hero > .wrap, .about-grid, .about-with-photo, .experience-card, .project-layout { grid-template-columns: minmax(0, 1fr); }
  .hero > .wrap { display: grid; }
  .personal-carousel { display: grid; grid-template-columns: minmax(0, 1fr); }
  .personal-gallery .personal-image-frame { aspect-ratio: 16 / 9; }
  .project-grid, .managed-cert-grid, .managed-achievement-grid { grid-template-columns: minmax(0, 1fr); }
  .timeline-row { grid-template-columns: minmax(0, 1fr); }
  .activity-frame { width: 100%; }
  .showcase-toolbar .micro { font-size: 11px; }
  .carousel-status { font-size: 13px; }
  .project-showcase .showcase-slide { width: calc(100% - 28px); border-radius: 18px; }
  .project-showcase .slide-copy { padding: 20px; }
  .project-showcase .slide-copy h3 { font-size: 25px; }
  .project-showcase .showcase-stage { perspective: none; }
  .project-showcase .showcase-slide:not(.is-active) { pointer-events: none; }
  .gallery-thumbnails > button, .react-gallery-thumbs > button, .personal-thumbs > button { width: 88px; flex-basis: 88px; }
  dialog.portfolio-modal, dialog.image-lightbox, dialog.certificate-dialog, .media-picker dialog { width: calc(100vw - 20px); max-width: calc(100vw - 20px); max-height: calc(100dvh - 24px); padding: 12px; border-radius: 16px; }
  .lightbox-image-wrap > button, .certificate-dialog-image-wrap > button { width: 40px; height: 40px; }
  .admin-screenshot { grid-template-columns: minmax(0, 1fr); padding: 10px; }
  .admin-screenshot img { width: 100%; }
  .admin-form fieldset { min-width: 0; padding: 12px; }
  .admin-panel { padding: 18px; }
  .admin-sidebar nav a { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .reveal-waiting { opacity: 1; translate: none; }
}
@media (max-width: 760px) {
  .project-showcase .showcase-slide.is-active { transform: translateX(-50%) !important; }
  .project-showcase .showcase-slide:not(.is-active) { visibility: hidden !important; opacity: 0 !important; }
}
.gallery-order-editor > .admin-heading p { margin-top: 8px; font-size: 15px; }
.gallery-order-preview { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.gallery-order-preview img { width: min(200px, 100%); height: auto; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 10px; }
.gallery-order-editor > .admin-actions { margin-top: 20px; }
.restored-project .gallery-slide > img { max-height: none; aspect-ratio: 16 / 9; }
.personal-gallery .personal-image-frame { position: relative; }
.personal-image-frame .gallery-expand { z-index: 2; }
.project-showcase .slide-copy .tags span { font-size: 12px; line-height: 1.5; }
/* Match the specificity of legacy collection rules. */
.managed-experience-list .collection-photo,
.managed-achievement-grid .collection-photo {
  width: 100%; height: auto; min-height: 0; aspect-ratio: 16 / 9;
}
.managed-experience-list .collection-photo img,
.managed-achievement-grid .collection-photo img {
  width: 100%; height: 100%; max-height: none; aspect-ratio: 16 / 9; object-fit: cover;
}
.restored-project .gallery-slide > img { object-fit: cover; }
