/* ==== Document layout ==== */
html {
  background-color: #0d0b0f;
  color: #ffffff;
  font-size: 100%;
}

body {
  box-sizing: border-box;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  margin: 0;
  padding: 20px 30px 0;
}

body, button {
  font-family: "Inter", system-ui, sans-serif;
  font-weight: 400;
  font-size: 1.125rem;
  line-height: 1.6;
}

main {
  display: flex;
  flex-direction: column;
  height: 100%;
}

main > header > form {
    display: none;
  }

button {
  appearance: none;
}

button, input {
  cursor: pointer;
}

footer {
  color: gray;
  margin-bottom: 15px;
}

/* ==== Typography ==== */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  margin: .5625rem 0 .1875rem;
  line-height: 1.25;
}

h1 {
  margin-top: 0;
  font-size: 4rem;
  line-height: 1.125;
}

h2 {
  font-size: 2rem;
}

p {
  margin: 0 0 1.125rem;
}

a {
  color: unset;
  text-decoration-color: #6a5eff;
  text-decoration-thickness: .13em;
	text-underline-offset: .15em;
}

figcaption {
  margin-top: .5625rem;
  font-size: .875em;
}

small {
  font-size: .5em;
}

dialog small {
  font-size: .75em;
  line-height: 1.25;
} 

sup, sub {
  line-height: 0;
}

.focus {
  font-size: 1.25em;
}

.roman {
  font-style: unset;
}

.uppercase {
  text-transform: uppercase;
}

.lowercase {
  text-transform: lowercase;
}

.dinkus {
	border: none;
	margin: 1.6875rem 0;
}
.dinkus::before {
	content: "*\2007*\2007*";
	display: block;
	text-align: center;
	color: gray;
}

footer, code, legend, fieldset label {
  font-family: "DejaVu Sans Mono", "Menlo", monospace;
  font-weight: 400;
  font-size: .95rem;
}

/* ==== Elements ==== */

/* == Ptable grid == */
.g1 {grid-column: 1;}
.g2 {grid-column: 2;}
.g3 {grid-column: 3;}
.g4, .l1, .a1 {grid-column: 4;}
.g5, .l2, .a2 {grid-column: 5;}
.g6, .l3, .a3 {grid-column: 6;}
.g7, .l4, .a4 {grid-column: 7;}
.g8, .l5, .a5 {grid-column: 8;}
.g9, .l6, .a6 {grid-column: 9;}
.g10, .l7, .a7 {grid-column: 10;}
.g11, .l8, .a8 {grid-column: 11;}
.g12, .l9, .a9 {grid-column: 12;}
.g13, .l10, .a10 {grid-column: 13;}
.g14, .l11, .a11 {grid-column: 14;}
.g15, .l12, .a12 {grid-column: 15;}
.g16, .l13, .a13 {grid-column: 16;}
.g17, .l14, .a14 {grid-column: 17;}
.g18, .l15, .a15 {grid-column: 18;}

.p1 {grid-row: 1;}
.p2 {grid-row: 2;}
.p3 {grid-row: 3;}
.p4 {grid-row: 4;}
.p5 {grid-row: 5;}
.p6 {grid-row: 6;}
.p7 {grid-row: 7;}
nav > [class^="l"]{grid-row: 9;}
nav > [class^="a"]{grid-row: 10;}

.tablewrapper {
  --tablePad: 75px;
  --rowGap: 30px;
  container-type: size;
  min-height: calc(504px + var(--rowGap) + var(--tablePad));
  height: 100%;
}

nav {
  --cell: max(
    48px,
    min(
      calc((100cqh - var(--rowGap) - var(--tablePad) - (9 * 8px)) / 9),
      calc((100vw - 60px - (17 * 8px)) / 18)
    )
  );
  box-sizing: border-box;
  display: grid;
  grid-template-rows: repeat(7, var(--cell)) var(--rowGap) repeat(2, var(--cell));
  grid-template-columns: repeat(18, var(--cell));
  gap: 8px;
  margin: 0;
  padding: 30px 0 45px;
  height: 100%;
  border: none;
}

nav * {
  display: block;
  position: relative;
  line-height: 1;
}

nav > * {
  position: relative;
  display: grid;
  box-sizing: border-box;
  overflow: hidden;
  height: auto;
  aspect-ratio: 1;
  border: 2px solid white;
  border-radius: 8px;
  padding: 0;
  color: unset;
  background-color: unset;
  text-align: unset;
}

nav > button {
  cursor: pointer;
}

nav > div {
  cursor: default;
}

nav picture, nav img, nav .cell {
  position: absolute;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

nav .cell {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  margin: 0;
  padding: 4px;
  background-color: #00000050;
  font-size: calc(.5 * var(--cell));
  line-height: 1;
}

nav span[role="img"] {
  font-weight: 500;
}

nav > div {
  border-color: gray;
  color: gray;
}

@media (max-width: 1060px) {
  body {
    padding: 15px 15px 0;
  }

  h1 {
    font-size: 2.25rem;
  }

  main > header > form {
    display: unset;
  }
  fieldset {
    display: block;
    margin: 0;
    padding: 0 8px 8px;
    border: 1.5px solid gray;
    border-radius: 8px;
    min-inline-size: 0;
    cursor: default;
  }
  fieldset > * {
    display: inline-block;
  }
  legend {
    color: gray;
    padding: 0 4px;
    cursor: default;
  }
  fieldset input {
    margin: 0 4px;
  }
  fieldset label, fieldset div {
    cursor: pointer;
  }
  fieldset span {
    font-size: 20px;
    margin: 0 8px;
    cursor: default;
  }

  .tablewrapper {
    --rowGap: 15px;
    --tablePad: 30px;
    min-height: calc(342px + var(--rowGap) + var(--tablePad));
  }
  nav {
    --cell: clamp(
      30px,
      calc((100cqh - var(--rowGap) - var(--tablePad) - (9 * 8px)) / 9),
      48px
    );
    padding: 15px 0;
    overflow-x: scroll;
  }
  nav > * {
    border-width: 1.5px;
  }
  nav .cell {
    padding: 3px;
  }

  footer {
    margin-bottom: 10px;
  }

  body:has(#grid:checked) {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
  }
  main:has(#grid:checked) .tablewrapper {
    container-type: normal;
    min-height: unset;
  }
  main:has(#grid:checked) nav {
    --cell: calc((100vw - 30px - 2 * 12px) / 3);
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: unset;
    grid-auto-rows: max-content;
    gap: 12px;
    height: unset;
  }
  main:has(#grid:checked) nav > div {
    display: none;
  }
  main:has(#grid:checked) nav > button {
    grid-row: unset;
    grid-column: unset;
    border-width: 3px;
  }
  main:has(#grid:checked) nav .cell {
    padding: 6px;
  }
  main:has(#grid:checked) footer {
    margin-top: 15px;
  }
}

/* == Lightbox == */
dialog:modal {
  box-sizing: border-box;
  overscroll-behavior: contain;
  display: grid;
  grid-auto-rows: max-content;
  grid-template-columns: minmax(0, 750px);
  justify-content: center;
  position: fixed;
  max-width: unset;
  max-height: unset;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  padding: 15px;
  background-color: #0d0b0f;
  color: #ffffff;
  border: none;
}

dialog::background {
  overscroll-behavior: contain;
}

dialog > form {
  position: fixed;
  top: 15px;
  right: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  width: 30px;
  border: white;
}

dialog > form button {
  border: none;
  background-color: transparent;
  font-size: 30px;
  line-height: 0;
  text-align: center;
  margin-bottom: 4px;
  padding: 0;
  color: inherit;
}

dialog > header {
  height: auto;
  margin-bottom: 1.5rem;
  margin-right: 38px;
}

dialog > header h2 {
  margin: 0 0 .5625rem;
  text-wrap: balance;
}

dialog > header > a {
  display: flex;
  align-items: center;
  width: fit-content;
}

dialog > header > a > * {
  display: block;
}

dialog > header picture {
  margin-right: 8px;
  margin-left: 4px;
}

dialog > header img {
  display: block;
  border-radius: 50%;
  height: 24px;
  width: 24px;
}

dialog figure {
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 750px;
  margin-bottom: 1.25rem;
}

dialog figure img {
  display: block;
  width: 100%;
  height: auto;
}

dialog > div p {
  font-size: 1.25rem;
}

@media (min-width: 780px) {
  dialog:modal {
    grid-template-columns: 320px minmax(0, 750px);
    column-gap: 15px;
    grid-template-rows: max-content 1fr;
    padding-top: 30px;
  }
  dialog figure {
    grid-row: span 2;
  }
  dialog figure img {
    width: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
  }
  dialog header {
    margin-right: 0;
  }
  dialog header h2 {
    margin-top: -.25rem;
  }
  dialog > div {
    overflow-y: scroll;
  }
}