/* =========================================================
   BASE — shared by every page
   1. Tokens
   2. Reset + elements
   3. Display tools (font / contrast)
   4. Navigation bars
   5. Main column
   6. News column + newsletter
   7. Tablet / mobile layout
   8. Print
   ========================================================= */


/* 1. Tokens
   ========================================================= */
:root {
  --bg: #f2eaea;
  --fg: black;
  --contrast-bg: #1C1F15;
  --contrast-fg: #eee;
  --desktop-gutter: 30px;
  --mobile-gutter: 15px;
  --nav-row-height: 40px;
  --footer-height: 80px;
  --mobile-footer-height: 120px;
  --newsletter-width: 360px;

  /* Type: three sizes and two line heights for the whole site. */
  --size-text: 21px;     /* reading text, titles of entries */
  --size-meta: 18.5px;   /* dates, places, credits, links, filters (16px on mobile) */
  --size-note: 14.5px;   /* captions, News, footnotes */
  --leading-text: 1.24;  /* paragraphs */
  --leading: 1.22;       /* everything else */
  --paragraph-gap: calc(30px * var(--text-scale)); /* between two paragraphs, everywhere */
  /* The only drop shadow of the site, on rectangular images (box-shadow: much
     lighter for the browser than filter: drop-shadow, same look). */
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  --shadow-small: 0 2px 5px rgba(0, 0, 0, 0.15); /* the small book thumbnails of Writing (as on samiahenni.com) */
  --colour-fade: 0s; /* grey to colour: instant, everywhere */

  /* Set by the "+" / "−" buttons (js/preferences.js, js/common.js). Menus and h1 titles keep their size. */
  --text-scale: 1;
}

@media screen and (max-width: 760px) {
  :root {
    --size-meta: 16px;
  }
}


/* 2. Reset + elements
   ========================================================= */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-color: color-mix(in srgb, var(--fg) 18%, transparent) transparent;
  scrollbar-width: thin;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: "Century School", "Times New Roman", Times, serif;
}

a {
  color: inherit;
  text-decoration: none;
}

h1 {
  font-size: 18.5px;
  font-weight: normal;
  line-height: var(--nav-row-height);
  text-align: center;
  text-transform: uppercase;
}

h2 {
  font-size: calc(var(--size-meta) * var(--text-scale));
  font-weight: normal;
  text-align: center;
}

p {
  padding: 15px 0;
  font-size: calc(var(--size-text) * var(--text-scale));
  line-height: var(--leading-text);
}

/* Between two paragraphs: one shared gap (outer spacing unchanged). */
p:has(+ p) {
  padding-bottom: var(--paragraph-gap);
}

p + p {
  padding-top: 0;
}

img {
  width: 100%;
}

::-webkit-scrollbar {
  width: 1px;
}

::-webkit-scrollbar-thumb {
  background: var(--fg);
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}


/* 3. Display tools (font / contrast)
   ========================================================= */
html.font-helvetica,
html.font-helvetica input,
html.font-helvetica textarea,
html.font-helvetica select,
html.font-helvetica button {
  font-family: Helvetica, Arial, sans-serif;
}

html.contrast-mode {
  --bg: var(--contrast-bg);
  --fg: var(--contrast-fg);
}

html.contrast-mode input,
html.contrast-mode textarea,
html.contrast-mode select {
  color: var(--contrast-fg);
  border-color: var(--contrast-fg);
}

/* On the dark background, images stay grey but are not multiplied. */
html.contrast-mode img,
html.contrast-mode canvas {
  mix-blend-mode: normal !important;
}


/* 4. Navigation bars
   Desktop: two fixed rows at the bottom of the main column.
   Mobile (≤939px): three rows, see section 7.
   ========================================================= */
.mobile-menu,
#mobile-nav {
  display: none;
}

.nav-placeholder {
  opacity: 0;
}

nav .theme-nav {
  position: fixed;
  z-index: 3;
  left: var(--desktop-gutter);
  width: calc(100vw - var(--newsletter-width) - (2 * var(--desktop-gutter)));
  height: var(--nav-row-height);
  background: var(--bg);
  border-top: 1px solid var(--fg);
}

.theme-nav.row-bottom { bottom: 0; }
.theme-nav.row-middle { bottom: var(--nav-row-height); }
.theme-nav.row-top { bottom: var(--footer-height); }

.theme-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.theme-nav .theme-item {
  font-size: var(--size-text);
  line-height: var(--nav-row-height);
  text-align: center;
}

.theme-item a {
  display: inline-block;
  min-width: max-content;
}

/* Hover = slight italic skew, used by every menu-like control. */
.theme-item a:hover,
.newsletter-form button:hover,
.mobile-menu h1:hover {
  transform: skewX(-10deg);
}


/* 5. Main column
   ========================================================= */
main .content {
  float: left;
  position: relative;
  width: calc(100vw - var(--newsletter-width) - var(--desktop-gutter) - var(--mobile-gutter));
  margin-left: var(--desktop-gutter);
  margin-right: var(--mobile-gutter);
  overflow-x: hidden;
  overflow-y: scroll;
}

#content-article {
  height: calc(100vh - var(--footer-height));
  scroll-behavior: smooth;
}

.content a {
  text-decoration: underline;
}

/* "↗" / "↓" after a link label: outside the underline (inline-block). */
.link-arrow {
  display: inline-block;
  margin-left: 0.25em;
  text-decoration: none;
}

.content .column#column-left {
  padding-right: 45px;
  padding-left: var(--desktop-gutter);
}

/* On desktop, the first block begins below the 40px NEWS bar. */
@media screen and (min-width: 1121px) {
  #start {
    margin-top: var(--nav-row-height);
  }
}

/* Inline links that preview an image under the cursor (biography). */
.hover-link:hover {
  text-decoration: none;
  filter: blur(1px);
}

.hover-image {
  position: fixed;
  z-index: 1000;
  display: none;
  width: auto;
  height: auto;
  max-width: min(400px, calc(100vw - 40px));
  max-height: calc(100vh - 160px);
  pointer-events: none;
  box-shadow: var(--shadow);
  transition: opacity 0.3s ease;
}


/* 6. News column + newsletter
   ========================================================= */
.events {
  float: left;
  position: relative;
  width: var(--newsletter-width);
  min-width: var(--newsletter-width);
  max-width: var(--newsletter-width);
  height: calc(100vh - var(--footer-height));
  overflow-x: hidden;
  overflow-y: scroll;
  background: var(--bg);
}

.events h1 {
  width: calc(100% - var(--desktop-gutter));
  height: var(--nav-row-height);
}

.events p {
  padding: 10px 0;
  font-size: calc(var(--size-note) * var(--text-scale));
  line-height: var(--leading);
}

.event-column {
  width: calc(100% - var(--desktop-gutter));
  height: calc(100vh - 120px);
  overflow-y: scroll;
}

.event-caption {
  margin-top: -10px;
}

.events figure {
  background: var(--bg);
}

.event-image {
  display: block;
  margin: 10px 0;
}

/* Photographs (exhibitions, posters, News): grey, printed into the background
   (multiply) at rest, in colour on hover — or, on touch screens, while they
   cross the middle of the screen (.colour-copy, below). Article figures turn to colour on
   scroll instead (css/article.css). */
.event-image,
.exhibition-slide img,
.exhibition-single-visual img,
.archive-visual img {
  filter: grayscale(100%);
  mix-blend-mode: multiply;
  transition: filter var(--colour-fade);
}

.event-image:hover,
.exhibition-carousel:hover .exhibition-slide.is-active img,
.exhibition-carousel:focus-visible .exhibition-slide.is-active img,
.exhibition-single-visual:hover img,
.archive-visual:hover img,
.archive-visual:focus-within img {
  filter: grayscale(0%);
  mix-blend-mode: normal;
}

/* Touch screens: colour copy laid over a grey image while it crosses the
   reading line (js/common.js), faded in like the article images.
   !important: the copy sits where the rules of each image (size, filter,
   shadow, transition) would otherwise apply to it too. */
.colour-copy {
  position: absolute !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  opacity: 0 !important;
  filter: none !important;
  mix-blend-mode: normal !important;
  box-shadow: none !important;
  transform: none !important;
  transition: opacity 0.7s ease !important;
  pointer-events: none;
}

.colour-copy.is-coloured {
  opacity: 1 !important;
}

span.separation,
span.spacer {
  display: block;
  border-top: 1px solid var(--fg);
}

span.spacer {
  position: absolute;
  z-index: 100;
  width: calc(100% - var(--desktop-gutter));
}

footer {
  position: fixed;
  right: var(--desktop-gutter);
  bottom: 0;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  width: calc(var(--newsletter-width) - var(--desktop-gutter));
  height: var(--footer-height);
  background: var(--bg);
  border-top: 1px solid var(--fg);
}

.newsletter {
  display: grid;
  grid-template-rows: var(--nav-row-height) var(--nav-row-height);
  width: 100%;
  height: var(--footer-height);
}

.newsletter h1 {
  width: 100%;
  text-align: left;
}

.newsletter-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  column-gap: 12px;
  align-items: center;
  width: 100%;
  height: var(--nav-row-height);
}

.newsletter-form input {
  width: 100%;
  min-width: 0;
  height: var(--nav-row-height);
  border: 0;
  outline: none;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: var(--size-text);
  line-height: var(--nav-row-height);
}

.newsletter-form input::placeholder {
  color: color-mix(in srgb, var(--fg) 55%, transparent);
  opacity: 1;
}

.newsletter-form button {
  justify-self: end;
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-size: var(--size-text);
  line-height: var(--nav-row-height);
  white-space: nowrap;
}

/* Copy of the newsletter shown inside the sliding News panel (≤1120px). */
.mobile-newsletter-footer {
  display: none;
}


/* 7. Tablet / mobile layout
   ≤1120px: News becomes a sliding panel opened from the top bar.
   ≤939px:  the navigation switches to its three-row mobile version.
   ≤475px:  News panel takes the full width, smaller type.
   ========================================================= */
@media screen and (max-width: 1120px) {
  /* LIBRARY is already shown in the top bar. */
  #desktop-nav .desktop-library-link {
    display: none;
  }

  ::-webkit-scrollbar-thumb {
    background: transparent;
  }

  .mobile-menu {
    position: fixed;
    z-index: 4;
    left: var(--mobile-gutter);
    display: block;
    width: calc(100% - (2 * var(--mobile-gutter)));
    height: var(--nav-row-height);
    background: var(--bg);
    border-bottom: 1px solid var(--fg);
  }

  /* Room for the skew on hover (Safari clipped the slanted letters at the
     edge of the box and left marks next to it): an invisible 8px margin on
     each side, cancelled by a negative margin, so nothing moves. */
  .mobile-menu h1 {
    padding: 0 8px;
    margin: 0 -8px;
    cursor: pointer;
    will-change: transform;
  }

  .mobile-menu h1#library-menu { float: left; }
  .mobile-menu h1#news-menu { float: right; }

  nav .theme-nav {
    left: var(--mobile-gutter);
    width: calc(100% - (2 * var(--mobile-gutter)));
  }

  .theme-nav .theme-item {
    padding-left: 10px;
  }

  .theme-nav .font-control {
    padding-left: 0;
  }

  main .content {
    width: 100%;
    margin-left: 0;
  }

  main .content .column#column-left {
    padding-right: 45px;
    padding-left: 45px;
  }

  #content-article {
    position: absolute;
    top: var(--nav-row-height);
    right: 0;
    left: 0;
    width: 100%;
    height: auto;
    margin-right: 0;
  }

  footer {
    display: none;
  }

  .events {
    position: fixed;
    z-index: 10;
    top: var(--nav-row-height);
    right: 0;
    bottom: 0;
    width: var(--newsletter-width);
    min-width: 0;
    max-width: var(--newsletter-width);
    height: auto;
    overflow: hidden;
    transform: translateX(calc(100% + var(--mobile-gutter)));
    /* Hidden once closed, so no part of it can show at the edge of the screen. */
    visibility: hidden;
    transition: transform 0.45s ease, visibility 0s linear 0.45s;
  }

  .events.is-open {
    transform: translateX(0);
    visibility: visible;
    transition: transform 0.45s ease;
  }

  .events > h1,
  .events > span.spacer {
    display: none;
  }

  .events .event-column {
    position: absolute;
    top: 0;
    right: var(--mobile-gutter);
    bottom: var(--footer-height);
    left: var(--mobile-gutter);
    width: auto;
    height: auto;
    overflow-x: hidden;
  }

  .mobile-newsletter-footer {
    position: absolute;
    right: var(--mobile-gutter);
    bottom: 0;
    left: var(--mobile-gutter);
    display: flex;
    align-items: flex-start;
    height: var(--footer-height);
    background: var(--bg);
    border-top: 1px solid var(--fg);
  }

  body.newsletter-open {
    overflow: hidden;
  }
}

@media screen and (min-width: 940px) and (max-width: 1120px) {
  #content-article {
    bottom: var(--footer-height);
  }
}

@media screen and (max-width: 939px) {
  #desktop-nav { display: none; }
  #mobile-nav { display: block; }

  #content-article {
    bottom: var(--mobile-footer-height);
  }
}

@media screen and (max-width: 475px) {
  .events {
    right: 0;
    left: 0;
    width: 100vw;
    max-width: none;
    transform: translateX(100%);
  }

  h1,
  .newsletter-form input,
  .newsletter-form button,
  .theme-nav .theme-item {
    font-size: 16px;
  }

  main .content .column#column-left {
    padding-right: 30px;
    padding-left: 30px;
  }
}


/* 8. Print — main column 75% + News 25%
   ========================================================= */
@media print {
  nav,
  .mobile-menu,
  footer,
  .mobile-newsletter-footer {
    display: none !important;
  }

  html,
  body {
    background: white !important;
    color: black !important;
  }

  main {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
  }

  main .content,
  #content-article {
    display: block !important;
    float: left !important;
    position: relative !important;
    width: calc(75% - 15px) !important;
    height: auto !important;
    margin: 0 15px 0 0 !important;
    overflow: visible !important;
  }

  #column-left {
    display: block !important;
    width: auto !important;
    height: auto !important;
    padding-right: 15px !important;
    padding-left: 30px !important;
    overflow: visible !important;
  }

  .events {
    display: block !important;
    float: left !important;
    position: relative !important;
    width: 25% !important;
    min-width: 0 !important;
    max-width: none !important;
    height: auto !important;
    padding: 0 !important;
    overflow: visible !important;
    transform: none !important;
  }

  .events h1,
  .events .event-column,
  .events > span.spacer {
    width: calc(100% - 30px) !important;
  }

  .events .event-column {
    position: static !important;
    height: auto !important;
    margin-top: -3px !important;
    overflow: visible !important;
  }

  a {
    color: black !important;
    text-decoration: none !important;
  }

  @page {
    margin: 12mm;
  }
}
