/*
 * The public site, on every screen: one centred column, in reading order:
 * logo, categories, open project list, slideshow, project facts, colophon, languages.
 * Linked from home/index only; the admin shares the layout and keeps the wide canvas.
 */
html, body {
  height:                   auto;
  font-size:                17px;
  line-height:              1.45;
  -webkit-text-size-adjust: 100%;
}

body {
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

table.layout,
table.layout > tbody,
table.layout > tbody > tr,
table.layout > tbody > tr > td {
  display: block;
  width:   auto;
  height:  auto;
}

/* a column wider than this only stretches the slideshow and the ruled lines */
#canvas, #footer {
  max-width: 600px;
  margin:    0 auto;
}

/* One edge for every panel (project list, slideshow frame, project facts, address
   lines), one inset for the text inside them, one veil for what lies over the plan. */
#canvas {
  --gutter:       12px;
  --inset:        20px;
  --veil:         rgba(255, 255, 255, 0.68);
  --hairline:     rgba(0, 0, 0, 0.09);
  display:        flex;
  flex-direction: column;
  width:          auto;
  height:         auto;
  padding-top:    20px;
}

/* the site plan, fitted into the window at full height and centred behind the column, stays put while it scrolls;
   paled so the words read (on white by day, on black at night, the same opacity does both) */
#plan {
  position: fixed;
}
#plan img {
  top:             0;
  left:            0;
  width:           100%;
  height:          100%;
  object-fit:      contain;
  object-position: center;
  opacity:         0.4;
}
/* a window narrower than the plan (a phone held upright): the plan still fills
   the full height, and its sides are cut off evenly */
@media (max-aspect-ratio: 1024/818) {
  #plan img { object-fit: cover; }
}

/* logo */
#logo        { order: 1; align-self: center; }
#logo img    { position: static; display: block; width: 120px; height: 120px; }

/* categories: the eight coloured words wrap into a centred block */
#maintable {
  order:    2;
  position: static;
  margin:   24px 8px 6px;
}
#maintable tbody, #maintable tr {
  display:         flex;
  flex-wrap:       wrap;
  justify-content: center;
}
#maintable td.h1 {
  padding:     0;
  font-size:   25px;
  line-height: 1;
}
#maintable td.h1 a {
  display: block;
  padding: 10px 9px;
}

/* project list of the open category: drops down from under the words and lies
   over the slideshow instead of pushing it down (home.js sets its top).
   A veil, not a sheet: the picture underneath stays present but softened. */
.main_menu {
  position:         absolute;
  left:             var(--gutter);
  right:            var(--gutter);
  z-index:          20;
  max-width:        none;
  margin:           6px 0 0;
  padding:          4px var(--inset) 6px;
  border-top:       2px solid currentColor;
  background-color: var(--veil);
  -webkit-backdrop-filter: blur(4px) saturate(1.1);
          backdrop-filter: blur(4px) saturate(1.1);
  box-shadow:       0 14px 28px -12px rgba(0, 0, 0, 0.28);
}
.main_menu ul      { margin: 0; }
.main_menu li + li { border-top: 1px solid var(--hairline); }
.main_menu li a {
  display:    block;
  padding:    11px 0;
  transition: color 0.15s ease-out;
}
/* hover and the current project take the category's colour */
.main_menu li a:hover { color: inherit; }

/* slideshow: the picture on a mat of the veil, in a fixed 420:270 frame */
.gallery {
  order:            4;
  position:         relative;
  margin:           20px var(--gutter) 0;
  padding:          6px 6px 0;
  border:           1px solid transparent;
  background-color: var(--veil);
  -webkit-backdrop-filter: blur(4px);
          backdrop-filter: blur(4px);
}
.gallery[hidden]   { display: none; }
.gallery.is-project { border-color: #000; }  /* a project's own pictures, not the promotions */

.gallery-stage {
  position:         relative;
  aspect-ratio:     420 / 270;
  overflow:         hidden;
  background-color: rgba(0, 0, 0, 0.06);
}
.gallery-image {
  display:    block;
  width:      100%;
  height:     100%;
  object-fit: cover;
  cursor:     pointer;
  transition: opacity 0.24s ease-out;
}
.gallery-image.is-faded  { opacity: 0; }
.gallery-image:not([src]) { visibility: hidden; }

/* the project's name, over the picture for a few seconds when it changes */
.gallery-title {
  position:       absolute;
  top:            14%;
  left:           6%;
  right:          6%;
  margin:         0;
  color:          #fff;
  font-size:      clamp(28px, 8vw, 44px);
  line-height:    1.1;
  text-align:     center;
  text-shadow:    0 2px 18px rgba(0, 0, 0, 0.45);
  opacity:        0;
  transition:     opacity 0.6s ease-out;
  pointer-events: none;
}
.gallery-title.is-shown { opacity: 1; }

.gallery-counter {
  position:         absolute;
  top:              8px;
  left:             8px;
  padding:          1px 8px;
  font-size:        14px;
  background-color: var(--veil);
  color:            #000;
}

/* prev / next: a veiled disc at each side, drawn, so it reads on any picture */
.gallery-prev, .gallery-next {
  position:   absolute;
  top:        0;
  bottom:     0;
  width:      56px;
  padding:    0;
  border:     0;
  background: none;
  cursor:     pointer;
  -webkit-tap-highlight-color: transparent;
}
.gallery-prev { left: 0; }
.gallery-next { right: 0; }
.gallery-prev::before, .gallery-next::before {
  content:          "";
  position:         absolute;
  top:              50%;
  left:             10px;
  width:            36px;
  height:           36px;
  margin-top:       -18px;
  border-radius:    50%;
  background-color: var(--veil);
  opacity:          0.85;
  transition:       opacity 0.15s ease-out;
}
.gallery-prev::after, .gallery-next::after {
  content:      "";
  position:     absolute;
  top:          50%;
  left:         24px;
  width:        9px;
  height:       9px;
  margin-top:   -5px;
  border-left:  2px solid #000;
  border-bottom: 2px solid #000;
  transform:    rotate(45deg);
}
.gallery-next::after { left: 21px; transform: rotate(-135deg); }
.gallery-prev:hover::before, .gallery-next:hover::before { opacity: 1; }
.gallery-prev:focus-visible, .gallery-next:focus-visible { outline: none; }
.gallery-prev:focus-visible::before, .gallery-next:focus-visible::before {
  opacity: 1;
  box-shadow: 0 0 0 2px #000;
}
.gallery.is-single .gallery-prev,
.gallery.is-single .gallery-next,
.gallery.is-single .gallery-counter { display: none; }

.gallery-caption {
  min-height:  1.35em;
  padding:     8px 10px 10px;
  line-height: 1.35;
  text-align:  right;
}

/* project facts */
#project_info {
  order:    5;
  position: static;
  width:    auto;
  margin:   12px var(--gutter) 0;
  background-color: var(--veil);
  -webkit-backdrop-filter: blur(4px);
          backdrop-filter: blur(4px);
}

/* colophon: address and pages, ruled lines across the column */
#navitable {
  order:    6;
  position: static;
  width:    calc(100% - 2 * var(--gutter));
  margin:   48px var(--gutter) 0;
  background-color: var(--veil);
  -webkit-backdrop-filter: blur(4px);
          backdrop-filter: blur(4px);
}
#navitable td:first-child { display: none; }
#navitable td {
  padding:        9px var(--inset);
  color:          #6e6e6e;  /* the grey of the address, dark enough to read over the plan */
  line-height:    26px;
  vertical-align: middle;
}
#navitable td.h2 { font-size: 24px; padding-top: 10px; }
#navitable a.popup { display: block; margin: -9px 0; padding: 9px 0; }
#navitable img { vertical-align: middle; }
#navitable td[style*="border:0"] img { padding: 11px 6px; }

/* text pages and promotions: a sheet over the column; any tap closes it */
#popup {
  position:   fixed;
  top:        0;
  bottom:     0;
  left:       0;
  right:      0;
  width:      auto;
  max-width:  600px;
  margin:     0 auto;
  max-height: none;
  padding:    0 var(--inset) max(32px, env(safe-area-inset-bottom));
  border:     0;
  z-index:    100;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
/* on a wide screen the sheet gets its edges back, and some air above and below */
@media (min-width: 640px) {
  #popup { top: 32px; bottom: 32px; border: 1px solid black; }
}
#popup::before {
  content:     "×";
  position:    sticky;
  top:         0;
  float:       right;
  margin:      0 -12px 0 8px;
  width:       44px;
  height:      44px;
  font:        normal 32px/44px georgia;
  text-align:  center;
  color:       #000;
  background:  #fff;
}
#popup li a { display: inline-block; padding: 8px 0; }

/* languages */
#footer {
  height:  auto;
  padding: 24px 20px 32px;
}
#langnav {
  position:   static;
  text-align: center;
}
#langnav a { display: inline-block; padding: 9px 6px; }

/* keyboard focus: a ring in the link's own colour */
#canvas a:focus-visible, #footer a:focus-visible {
  outline:        2px solid currentColor;
  outline-offset: 2px;
}
#maintable td.h1 a:focus-visible { outline-offset: -2px; }

::selection { background-color: rgba(90, 160, 150, 0.28); }
