/* Shared site, gallery, exhibition, viewer and about styles. */
/* General */

@font-face {
  font-family: "Calendas Plus";
  src: url("../fonts/calendas-plus/calendas_plus-webfont.woff2") format("woff2"), url("../fonts/calendas-plus/calendas_plus-webfont.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Calendas Plus";
  src: url("../fonts/calendas-plus/calendas_plus_bold-webfont.woff2") format("woff2"), url("../fonts/calendas-plus/calendas_plus_bold-webfont.woff") format("woff");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Calendas Plus";
  src: url("../fonts/calendas-plus/calendas_plus_italic-webfont.woff2") format("woff2"), url("../fonts/calendas-plus/calendas_plus_italic-webfont.woff") format("woff");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "Novela";
  src: url("../fonts/novela/novela-regular-webfont.woff2") format("woff2"), url("../fonts/novela/novela-regular-webfont.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Novela";
  src: url("../fonts/novela/novela-regularitalic-webfont.woff2") format("woff2"), url("../fonts/novela/novela-regularitalic-webfont.woff") format("woff");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "Novela";
  src: url("../fonts/novela/novela-semibold-webfont.woff2") format("woff2"), url("../fonts/novela/novela-semibold-webfont.woff") format("woff");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Novela";
  src: url("../fonts/novela/novela-semibolditalic-webfont.woff2") format("woff2"), url("../fonts/novela/novela-semibolditalic-webfont.woff") format("woff");
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

/* ============================================================
   THEME
   ============================================================ */

:root {
  --background: #faf9f6;
  --frame-background: #e4e0d8;
  --foreground: #171717;
  --muted: #77736d;
  --subtle: #aaa59e;
  --border: #d8d3cc;
  --border-hover: #bcb6ae;
  --hover-background: #f1eee9;
  --font-display: "Calendas Plus", serif;
  --font-text: "Novela", serif;
  --content-width: 1380px;
  --gallery-width: 1220px;
  --text-width: 680px;
}

/* ============================================================
   GLOBAL
   ============================================================ */

* {
  box-sizing: border-box;
}

html {
  margin: 0;
  padding: 0;
  background: var(--background);
  color: var(--foreground);
  overflow-y: scroll;
  scrollbar-gutter: stable;
}

.viewer-html {
  overflow: hidden;
  scrollbar-gutter: auto;
}

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-text);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
}

img {
  max-width: 100%;
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */

h1,
h2,
h3,
h4,
.gallery-title,
.viewer-title{
  font-family: var(--font-display);
  font-weight: 500;
  font-variant-ligatures:
    common-ligatures
    discretionary-ligatures
    contextual;

  font-feature-settings:
    "liga" 1,
    "dlig" 1,
    "salt" 1,
    "swsh" 1;
  text-transform: uppercase;
}

span.generated-book-cover-title{
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 20px;
  font-variant-ligatures:
    common-ligatures
    discretionary-ligatures
    contextual;

  font-feature-settings:
    "liga" 1,
    "dlig" 1,
    "salt" 1,
    "swsh" 1;
  text-transform: uppercase;
}

h1 {
  letter-spacing: -0.015em;
}

h2,
h3,
h4 {
  letter-spacing: -0.01em;
}

p,
li,
button,
input,
textarea,
select,
.viewer-description,
.image-counter {
  font-family: var(--font-text);
}

/* ============================================================
   GALLERY / EXHIBITION
   ============================================================ */

.gallery-page {
  min-height: 100vh;
  background: var(--frame-background);
  color: var(--foreground);
}

.gallery-shell {
  width: min(var(--content-width), calc(100% - 96px));
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(48px, 7vw, 100px) clamp(28px, 5vw, 72px) 100px;
  background: var(--background);
}

/* ------------------------------------------------------------
   Gallery header
   ------------------------------------------------------------ */

.gallery-header {
  position: relative;
  width: 100%;
  max-width: var(--gallery-width);
  margin: 0 auto clamp(42px, 6vw, 72px);
  text-align: center;
}

.gallery-header h1 {
  margin: 0;
  font-size: clamp(34px, 4vw, 52px);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.015em;
}

/* ------------------------------------------------------------
   Exhibition header
   ------------------------------------------------------------ */

.exhibition-header {
  position: relative;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ------------------------------------------------------------
   Gallery grid
   ------------------------------------------------------------ */

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 280px));
  justify-content: center;
  align-items: start;
  gap: clamp(32px, 4vw, 56px) clamp(20px, 3vw, 38px);
  width: 100%;
  max-width: var(--gallery-width);
  margin: 0 auto;
}

/* ------------------------------------------------------------
   Gallery item
   ------------------------------------------------------------ */

.gallery-item {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  color: inherit;
  text-decoration: none;
}

.gallery-item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-image-title {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 11px 14px 10px;
  background: rgba(250, 249, 246, 0.88);
  color: var(--foreground);
  font-family: var(--font-display);
  font-size: 16px;
  line-height: 1.2;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.gallery-caption {
  padding-top: 11px;
}

.gallery-title {
  font-size: 17px;
  font-weight: 400;
  line-height: 1.25;
  letter-spacing: -0.005em;
}

/* ============================================================
   EXHIBITION WORKS
   ============================================================ */

.exhibition-works {
  width: 100%;
  max-width: var(--gallery-width);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: clamp(90px, 12vw, 170px);
}

.exhibition-work {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  align-items: center;
  width: 100%;
}

.exhibition-image {
  display: block;
  grid-column: 1 / span 7;
  text-decoration: none;
  overflow: hidden;
}

.exhibition-image img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  transition: opacity 0.25s ease;
}

.exhibition-image:hover img {
  opacity: 0.9;
}

.exhibition-info {
  min-width: 0;
  grid-column: 8 / span 5;
  padding: clamp(26px, 4vw, 48px);
  background: var(--hover-background);
  border: 1px solid var(--border);
}

.exhibition-info h2 {
  margin: 0 0 1.6em;
  font-size: clamp(24px, 2.4vw, 38px);
  line-height: 1.02;
  font-weight: 400;
  max-width: 100%;
  overflow-wrap: break-word;
  hyphens: auto;
  text-wrap: balance;
}

.exhibition-meta {
  font-size: 15px;
  line-height: 1.45;
}

.exhibition-meta-row {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 12px;
  margin-bottom: 5px;
}

.exhibition-meta-label {
  color: var(--muted);
}

.exhibition-meta-value {
  color: var(--foreground);
}

.exhibition-text {
  margin: 2em 0 0;
  font-size: 16px;
  line-height: 1.6;
}

/* ------------------------------------------------------------
   Broken exhibition rhythm
   ------------------------------------------------------------ */

/* second work: image right, text left */

.exhibition-work:nth-child(3n + 2) .exhibition-image {
  grid-column: 6 / span 7;
  grid-row: 1;
}

.exhibition-work:nth-child(3n + 2) .exhibition-info {
  grid-column: 2 / span 4;
  grid-row: 1;
}

/* third work: slightly narrower and indented */

.exhibition-work:nth-child(3n) .exhibition-image {
  grid-column: 2 / span 6;
}

.exhibition-work:nth-child(3n) .exhibition-info {
  grid-column: 8 / span 5;
}

/* occasional extra vertical displacement */

.exhibition-work:nth-child(4n + 2) {
  margin-top: clamp(20px, 4vw, 55px);
}

.exhibition-work:nth-child(5n) {
  margin-bottom: clamp(20px, 5vw, 70px);
}

/* ============================================================
   FULL VIEWER
   ============================================================ */

.viewer-page {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: #111;
}

#viewer {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* ------------------------------------------------------------
   Viewer top bar
   ------------------------------------------------------------ */

.viewer-topbar {
  position: fixed;
  z-index: 1000;
  top: 0;
  left: 0;
  right: 0;
  min-height: 70px;
  padding: 10px 15px;
  display: flex;
  align-items: center;
  gap: 18px;
  color: #fff;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(5px);
}

.viewer-title-container {
  flex: 1;
  min-width: 0;
}

.viewer-title {
  font-size: 18px;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.viewer-description {
  margin-top: 3px;
  font-size: 13px;
  opacity: 0.75;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.viewer-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* ============================================================
   GENERIC VIEWER BUTTON
   Must occur before exhibition/about overrides below.
   ============================================================ */

.viewer-button {
  display: inline-block;
  min-width: 38px;
  padding: 9px 12px;
  border: none;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-family: var(--font-text);
  font-size: 14px;
  font-weight: 400;
  line-height: 1;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
}

.viewer-button:hover {
  background: rgba(255, 255, 255, 0.28);
}

/* ============================================================
   LIGHT-PAGE BUTTON OVERRIDES
   These MUST remain after .viewer-button.
   ============================================================ */

.exhibition-home-button,
.about-home-button {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  color: var(--foreground);
  border: 1px solid var(--border);
}

.exhibition-home-button:hover,
.about-home-button:hover {
  background: var(--hover-background);
  border-color: var(--border-hover);
}

/* ============================================================
   VIEWER PREVIOUS / NEXT
   ============================================================ */

.nav-button {
  position: fixed;
  z-index: 900;
  top: 50%;
  transform: translateY(-50%);
  width: 55px;
  height: 80px;
  border: none;
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  font-family: var(--font-text);
  font-size: 48px;
  font-weight: 400;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s ease, background 0.2s ease;
}

.nav-button:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.7);
}

.nav-previous {
  left: 0;
  border-radius: 0 5px 5px 0;
}

.nav-next {
  right: 0;
  border-radius: 5px 0 0 5px;
}

/* ------------------------------------------------------------
   Image counter
   ------------------------------------------------------------ */

.image-counter {
  position: fixed;
  z-index: 1000;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  padding: 7px 12px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 13px;
}

/* ============================================================
   ABOUT
   ============================================================ */

.about-page {
  min-height: 100vh;
  background: var(--frame-background);
  color: var(--foreground);
}

.about-shell {
  width: min(var(--content-width), calc(100% - 96px));
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(48px, 7vw, 100px) clamp(28px, 5vw, 72px) 100px;
  background: var(--background);
}

/* ------------------------------------------------------------
   About header
   ------------------------------------------------------------ */

.about-header {
  position: relative;
  width: 100%;
  max-width: var(--gallery-width);
  margin: 0 auto clamp(56px, 8vw, 92px);
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.about-header h1 {
  margin: 0;
  font-size: clamp(34px, 5vw, 54px);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.015em;
}

/* ------------------------------------------------------------
   About text
   ------------------------------------------------------------ */

.about-content {
  width: 100%;
  max-width: var(--text-width);
  margin: 0 auto;
  font-size: 17px;
  line-height: 1.72;
}

.about-content p {
  margin: 0 0 1.35em;
}

.about-intro {
  margin-bottom: 4em !important;
  font-family: var(--font-text);
  font-size: clamp(21px, 2.5vw, 27px);
  line-height: 1.45;
}

.about-content section {
  margin-top: 4.5em;
}

.about-content h2 {
  margin: 0 0 1.3em;
  font-size: 27px;
  font-weight: 400;
  line-height: 1.15;
}

.about-content a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--subtle);
  transition: border-color 0.2s ease;
}

.about-content a:hover {
  border-bottom-color: var(--foreground);
}

.about-content cite,
.about-content em {
  font-style: italic;
}

.about-ending {
  margin-top: 2.5em !important;
  font-family: var(--font-text);
  font-size: 22px;
}

/* ============================================================
   STANDARD TEXT LINKS
   ============================================================ */

.text-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--subtle);
  transition: border-color 0.2s ease;
}

.text-link:hover {
  border-bottom-color: var(--foreground);
}

/* ============================================================
   404
   ============================================================ */

.not-found-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--background);
  color: var(--foreground);
}

.not-found {
  max-width: 500px;
  padding: 40px;
  text-align: center;
}

.not-found h1 {
  margin: 0 0 12px;
  font-size: clamp(48px, 10vw, 96px);
  font-weight: 400;
  line-height: 1;
}

.not-found p {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.5;
}

.not-found a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--subtle);
  transition: border-color 0.2s ease;
}

.not-found a:hover {
  border-bottom-color: var(--foreground);
}

/* ============================================================
   TABLET
   ============================================================ */

@media (max-width:900px) {
  .gallery-shell {
    width: calc(100% - 40px);
    padding-left: 24px;
    padding-right: 24px;
  }

  .gallery {
    grid-template-columns: repeat(auto-fit, minmax(180px, 240px));
    gap: 36px 22px;
  }

  .about-shell {
    width: calc(100% - 40px);
    padding-left: 24px;
    padding-right: 24px;
  }

}

/* ============================================================
   PHONE
   ============================================================ */

@media (max-width:600px) {
  /* --------------------------------------------------------
       Gallery / exhibition
       -------------------------------------------------------- */

  .gallery-shell {
    width: 100%;
    padding: 36px 16px 60px;
  }

  .gallery-header {
    margin-bottom: 34px;
  }

  .gallery {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 28px 14px;
  }

  .gallery-title {
    font-size: 15px;
  }

  .about-shell {
    width: 100%;
    padding: 36px 18px 72px;
  }

  /* --------------------------------------------------------
       Exhibition home button
       -------------------------------------------------------- */

  .exhibition-header {
    padding-top: 52px;
  }

  .exhibition-home-button {
    top: 0;
    left: 50%;
    transform: translateX(-50%);
  }

  /* --------------------------------------------------------
       About
       -------------------------------------------------------- */

  .about-shell {
    padding: 36px 18px 72px;
  }

  .about-header {
    padding-top: 52px;
    margin-bottom: 54px;
  }

  .about-home-button {
    top: 0;
    left: 50%;
    transform: translateX(-50%);
  }

  .about-content {
    font-size: 16px;
    line-height: 1.68;
  }

  .about-content section {
    margin-top: 3.5em;
  }

  /* --------------------------------------------------------
       Full viewer
       -------------------------------------------------------- */

  .viewer-topbar {
    gap: 8px;
    padding: 8px;
    min-height: 60px;
  }

  .viewer-description {
    display: none;
  }

  .viewer-controls {
    gap: 3px;
  }

  .viewer-button {
    padding: 8px 9px;
    font-size: 13px;
  }

  /* Re-assert light-page styles after the mobile
       .viewer-button rule. */

  .exhibition-home-button,
  .about-home-button {
    background: transparent;
    color: var(--foreground);
    border: 1px solid var(--border);
  }

  .nav-button {
    width: 42px;
    height: 65px;
    font-size: 38px;
  }

}

@media (max-width:750px) {
  .exhibition-works {
    gap: 70px;
  }

  .exhibition-work {
    display: block;
    margin: 0 !important;
  }

  .exhibition-image {
    display: block;
    width: 100%;
  }

  .exhibition-info {
    width: calc(100% - 28px);
    margin: -1px auto 0;
    padding: 24px 22px;
  }

  .exhibition-info h2 {
    margin-bottom: 1.2em;
  }

}

/* ============================================================
   VERY SMALL VIEWER
   ============================================================ */

@media (max-width:560px) {
  #zoom-in-button,
  #zoom-out-button,
  #rotate-button {
    display: none;
  }

  .viewer-title {
    font-size: 15px;
  }

}

/* ============================================================
   VERY SMALL PHONE
   ============================================================ */

@media (max-width:380px) {
  .gallery {
    grid-template-columns: 1fr;
    max-width: 280px;
    margin: 0 auto;
  }

}
