/* Physical Gallery Wall, Frame Molding, Bevel Matboard & Archival Paper Simulation */

.gallery-wall {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse 75% 65% at 50% 38%, #EFECE5 0%, #E5E0D7 62%, #DBD5CA 100%);
  transition: background var(--dur-frame) var(--ease-editorial);
  overflow: hidden;
}

.gallery-wall.wall-alcove {
  background: radial-gradient(ellipse 72% 62% at 50% 38%, #2A2825 0%, #1C1B19 65%, #131210 100%);
}

/* Subtle plaster wall grain */
.gallery-wall::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.poster-stage {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: transform var(--dur-frame) var(--ease-editorial);
}

.poster-stage.room-scale {
  transform: scale(0.76) translateY(-10px);
}

/* Architectural room baseline & physical scale cue in Room mode */
.room-scale-caption {
  margin-top: 22px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ink-secondary);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity var(--dur-base) var(--ease-editorial), transform var(--dur-base) var(--ease-editorial);
  pointer-events: none;
}

.wall-alcove .room-scale-caption {
  color: rgba(247, 245, 240, 0.56);
}

.poster-stage.room-scale .room-scale-caption {
  opacity: 1;
  transform: translateY(0);
}

.room-scale-bar {
  width: 68px;
  height: 1px;
  background: currentColor;
  opacity: 0.45;
}

/* Frame Wrapper */
.frame-shell {
  --frame-w: clamp(13px, 1.65vw, 19px);
  position: relative;
  border-radius: 1.5px;
  transition:
    padding var(--dur-frame) var(--ease-editorial),
    background var(--dur-frame) var(--ease-editorial),
    box-shadow var(--dur-frame) var(--ease-editorial),
    transform var(--dur-frame) var(--ease-editorial);
}

/* 1. Unframed Paper */
.frame-shell.frame-paper {
  padding: 0;
  background: transparent;
  box-shadow: var(--shadow-unframed);
}

/* 2. Matte Black Gallery Frame */
.frame-shell.frame-black {
  padding: var(--frame-w);
  background: linear-gradient(145deg, #272624 0%, #171716 55%, #10100F 100%);
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, 0.10),
    inset -1px -1px 0 rgba(0, 0, 0, 0.65),
    var(--shadow-framed);
}

/* 3. Solid European White Oak Gallery Frame (True 45° Mitered Joinery) */
.frame-shell.frame-oak {
  --oak-grain-h: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='320' height='48' viewBox='0 0 320 48'%3E%3Cfilter id='b' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.006 0.085' numOctaves='2' seed='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0.36 0 0 0 0 0.24 0 0 0 0 0.12 0 0 0 0.38 -0.12'/%3E%3C/filter%3E%3Cfilter id='g' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.012 0.35' numOctaves='3' seed='11' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0.40 0 0 0 0 0.27 0 0 0 0 0.14 0 0 0 0.56 -0.17'/%3E%3C/filter%3E%3Crect width='320' height='48' filter='url(%23b)'/%3E%3Crect width='320' height='48' filter='url(%23g)'/%3E%3C/svg%3E");
  --oak-grain-v: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='320' viewBox='0 0 48 320'%3E%3Cfilter id='b' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.085 0.006' numOctaves='2' seed='9' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0.36 0 0 0 0 0.24 0 0 0 0 0.12 0 0 0 0.38 -0.12'/%3E%3C/filter%3E%3Cfilter id='g' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.35 0.012' numOctaves='3' seed='23' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0.40 0 0 0 0 0.27 0 0 0 0 0.14 0 0 0 0.56 -0.17'/%3E%3C/filter%3E%3Crect width='48' height='320' filter='url(%23b)'/%3E%3Crect width='48' height='320' filter='url(%23g)'/%3E%3C/svg%3E");

  padding: var(--frame-w);
  /* Warm oak seam substrate turns 0.5px diagonal anti-aliasing at 45° corners into a tight miter hairline */
  background: #94744C;
  box-shadow:
    0 0 0 0.5px rgba(72, 50, 26, 0.28),
    var(--shadow-framed);
}

/* Mitered Frame Rails — displayed on oak molding */
.frame-rail {
  display: none;
  position: absolute;
  pointer-events: none;
  z-index: 3;
}

.frame-shell.frame-oak .frame-rail {
  display: block;
}

/* Top Rail: horizontal grain, overhead sunlit outer chamfer, shadowed inner rabbet */
.frame-shell.frame-oak .frame-rail-top {
  top: 0;
  left: 0;
  right: 0;
  height: var(--frame-w);
  clip-path: polygon(0 0, 100% 0, calc(100% - var(--frame-w)) 100%, var(--frame-w) 100%);
  background-image:
    linear-gradient(
      180deg,
      rgba(255, 250, 238, 0.58) 0%,
      rgba(255, 248, 232, 0.18) 8%,
      rgba(255, 255, 255, 0.04) 22%,
      rgba(86, 58, 30, 0.05) 75%,
      rgba(74, 49, 24, 0.24) 85%,
      rgba(56, 36, 16, 0.44) 94%,
      rgba(38, 24, 10, 0.58) 100%
    ),
    var(--oak-grain-h),
    linear-gradient(90deg, #E3D0B1 0%, #DAC49E 52%, #D2B990 100%);
  background-size: 100% 100%, 320px 48px, 100% 100%;
  background-position: 0 0, 0 -4px, 0 0;
  background-repeat: no-repeat, repeat, no-repeat;
}

/* Bottom Rail: horizontal grain (offset for unique timber), deep underside shadow, sunlit inner rabbet ledge */
.frame-shell.frame-oak .frame-rail-bottom {
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--frame-w);
  clip-path: polygon(var(--frame-w) 0, calc(100% - var(--frame-w)) 0, 100% 100%, 0 100%);
  background-image:
    linear-gradient(
      0deg,
      rgba(48, 30, 14, 0.52) 0%,
      rgba(68, 44, 21, 0.22) 10%,
      rgba(0, 0, 0, 0.02) 26%,
      rgba(255, 248, 234, 0.06) 76%,
      rgba(255, 249, 236, 0.46) 89%,
      rgba(255, 248, 232, 0.24) 95%,
      rgba(52, 34, 15, 0.28) 100%
    ),
    var(--oak-grain-h),
    linear-gradient(90deg, #CAAF85 0%, #C0A174 52%, #B59567 100%);
  background-size: 100% 100%, 320px 48px, 100% 100%;
  background-position: 0 0, -142px -22px, 0 0;
  background-repeat: no-repeat, repeat, no-repeat;
}

/* Left Stile: vertical grain, soft left key-light catch, shaded inner rabbet */
.frame-shell.frame-oak .frame-rail-left {
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--frame-w);
  clip-path: polygon(0 0, 100% var(--frame-w), 100% calc(100% - var(--frame-w)), 0 100%);
  background-image:
    linear-gradient(
      90deg,
      rgba(255, 249, 236, 0.46) 0%,
      rgba(255, 247, 230, 0.14) 9%,
      rgba(255, 255, 255, 0.02) 24%,
      rgba(80, 54, 28, 0.06) 76%,
      rgba(68, 45, 22, 0.22) 86%,
      rgba(52, 34, 15, 0.38) 95%,
      rgba(38, 24, 10, 0.50) 100%
    ),
    var(--oak-grain-v),
    linear-gradient(180deg, #DBC59F 0%, #D2B990 55%, #C9AE84 100%);
  background-size: 100% 100%, 48px 320px, 100% 100%;
  background-position: 0 0, -6px 0, 0 0;
  background-repeat: no-repeat, repeat, no-repeat;
}

/* Right Stile: vertical grain (offset), richer shaded face, warm illuminated inner rabbet wall */
.frame-shell.frame-oak .frame-rail-right {
  top: 0;
  bottom: 0;
  right: 0;
  width: var(--frame-w);
  clip-path: polygon(0 var(--frame-w), 100% 0, 100% 100%, 0 calc(100% - var(--frame-w)));
  background-image:
    linear-gradient(
      270deg,
      rgba(56, 36, 16, 0.44) 0%,
      rgba(74, 49, 24, 0.18) 10%,
      rgba(0, 0, 0, 0.02) 26%,
      rgba(255, 248, 234, 0.05) 76%,
      rgba(255, 248, 234, 0.34) 89%,
      rgba(255, 246, 228, 0.18) 95%,
      rgba(52, 34, 15, 0.26) 100%
    ),
    var(--oak-grain-v),
    linear-gradient(180deg, #D0B78E 0%, #C5A97E 55%, #BA9B6E 100%);
  background-size: 100% 100%, 48px 320px, 100% 100%;
  background-position: 0 0, -24px -118px, 0 0;
  background-repeat: no-repeat, repeat, no-repeat;
}

/* Evening Alcove Calibration: deeper wall shadow & softer rim so pale oak sits naturally */
.wall-alcove .frame-shell.frame-oak {
  box-shadow:
    0 0 0 0.5px rgba(0, 0, 0, 0.55),
    0 4px 10px rgba(0, 0, 0, 0.38),
    0 22px 48px -6px rgba(0, 0, 0, 0.58),
    0 46px 90px -18px rgba(0, 0, 0, 0.68);
}

.wall-alcove .frame-shell.frame-oak .frame-rail-top,
.wall-alcove .frame-shell.frame-oak .frame-rail-left {
  filter: brightness(0.95) contrast(1.03);
}

/* 4. Gallery White Gesso Maple Frame */
.frame-shell.frame-white {
  padding: var(--frame-w);
  background: linear-gradient(145deg, #FAF8F4 0%, #EEEBE4 58%, #E3DFD6 100%);
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, 0.88),
    inset -1px -1px 0 rgba(26, 25, 23, 0.14),
    var(--shadow-framed);
}

/* Museum Rag Matboard & Recessed Rabbet Depth */
.mat-mount {
  position: relative;
  z-index: 1;
  padding: 0;
  background: transparent;
  transition: padding var(--dur-frame) var(--ease-editorial), background var(--dur-frame) var(--ease-editorial);
}

.frame-shell.has-mat:not(.frame-paper) .mat-mount {
  padding: clamp(16px, 2.8vh, 30px);
  background: #F7F5F0;
  box-shadow:
    inset 3px 5px 9px -2px rgba(32, 23, 14, 0.20),
    inset 1px 2px 3px rgba(32, 23, 14, 0.14),
    inset -1px -1px 1px rgba(255, 252, 245, 0.55);
}

.frame-shell.has-mat.mat-dark:not(.frame-paper) .mat-mount {
  background: #171716;
  box-shadow:
    inset 3px 5px 9px -2px rgba(0, 0, 0, 0.55),
    inset 1px 2px 3px rgba(0, 0, 0, 0.42);
}

/* Unmatted frame still casts recessed rabbet depth onto the print edge */
.frame-shell:not(.frame-paper):not(.has-mat) .mat-mount::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  box-shadow:
    inset 3px 5px 9px -2px rgba(28, 20, 12, 0.26),
    inset 1px 1.5px 2.5px rgba(28, 20, 12, 0.18);
}

/* Bevel-Cut Artwork Aperture */
.artwork-aperture {
  position: relative;
  line-height: 0;
  overflow: hidden;
  transition: opacity 220ms var(--ease-editorial), filter 220ms var(--ease-editorial);
}

.frame-shell.has-mat:not(.frame-paper) .artwork-aperture {
  box-shadow:
    0 0 0 1px rgba(26, 25, 23, 0.08),
    1px 1px 0 0.5px rgba(255, 255, 255, 0.85),
    inset 0 1px 2px rgba(26, 25, 23, 0.10);
}

.frame-shell.frame-paper .artwork-aperture {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.42);
}

/* Subtle cotton rag texture on paper */
.artwork-aperture::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.032;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23p)'/%3E%3C/svg%3E");
}

/* Anti-Reflective Museum Glass Sheen: strictly inside the molding (never glazing over raw matte oak wood) */
.frame-shell:not(.frame-paper) .mat-mount::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background: linear-gradient(
    126deg,
    rgba(255, 255, 255, 0.075) 0%,
    rgba(255, 255, 255, 0.025) 26%,
    rgba(255, 255, 255, 0) 44%
  );
}

/* Poster SVG Sizing */
.poster-svg-mount {
  display: block;
  width: 100%;
  height: 100%;
}

.poster-svg-mount svg,
.poster-svg-mount img {
  display: block;
  width: auto;
  height: auto;
  max-width: min(62vw, 640px);
  max-height: calc(100dvh - 270px);
  object-fit: contain;
}

.poster-svg-mount.is-landscape svg,
.poster-svg-mount.is-landscape img {
  max-width: min(60vw, 740px);
  max-height: calc(100dvh - 285px);
}

.frame-shell.has-mat:not(.frame-paper) .poster-svg-mount svg,
.frame-shell.has-mat:not(.frame-paper) .poster-svg-mount img {
  max-height: calc(100dvh - 332px);
}

/* Full-size A3 Studio Plate Placeholder: prevents frame collapsing into a tiny square on boot */
.studio-plate-placeholder {
  position: relative;
  height: calc(100dvh - 332px);
  max-height: 620px;
  min-height: 360px;
  aspect-ratio: 297 / 420;
  max-width: min(62vw, 520px);
  display: block;
  overflow: hidden;
}

.studio-plate-placeholder-inner {
  position: absolute;
  inset: 7.5% 8% 17.5% 8%;
  border: 1px solid currentColor;
  border-color: color-mix(in srgb, currentColor 16%, transparent);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.studio-plate-sweep {
  display: inline-flex;
  opacity: 0.85;
  animation: studio-azimuth-sweep 2.6s cubic-bezier(0.42, 0, 0.25, 1) infinite;
}

.studio-plate-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  opacity: 0.56;
}

.studio-plate-plaque-ghost {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 5.5%;
  height: 7.5%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.studio-plate-plaque-ghost span:first-child {
  width: 44%;
  height: 4px;
  background: currentColor;
  opacity: 0.13;
}

.studio-plate-plaque-ghost span:last-child {
  width: 28%;
  height: 2.5px;
  background: currentColor;
  opacity: 0.08;
}

@keyframes studio-azimuth-sweep {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.artwork-aperture.is-rendering {
  opacity: 0.84;
  filter: blur(0.45px);
}

/* Checkerboard hint when Transparent Paper is enabled */
.artwork-aperture.is-transparent {
  background-image:
    linear-gradient(45deg, rgba(26,25,23,0.045) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(26,25,23,0.045) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(26,25,23,0.045) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(26,25,23,0.045) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
}

@media (max-width: 960px) {
  .poster-svg-mount svg,
  .poster-svg-mount img,
  .poster-svg-mount.is-landscape svg,
  .poster-svg-mount.is-landscape img,
  .frame-shell.has-mat:not(.frame-paper) .poster-svg-mount svg,
  .frame-shell.has-mat:not(.frame-paper) .poster-svg-mount img,
  .studio-plate-placeholder {
    max-width: calc(100vw - 72px);
    max-height: 54dvh;
  }

  .frame-shell.frame-paper .poster-svg-mount svg,
  .frame-shell.frame-paper .poster-svg-mount img {
    max-width: calc(100vw - 40px);
  }
}

@media (max-width: 960px) and (min-height: 520px) {
  .canvas-column .poster-svg-mount svg,
  .canvas-column .poster-svg-mount img,
  .canvas-column .poster-svg-mount.is-landscape svg,
  .canvas-column .poster-svg-mount.is-landscape img,
  .canvas-column .frame-shell.has-mat:not(.frame-paper) .poster-svg-mount svg,
  .canvas-column .studio-plate-placeholder {
    max-height: calc(46dvh - 134px);
    max-width: calc(100vw - 64px);
  }
}
