:root {
  --brandDark: #46122b;
  --white: #fff6ff;
  --whiteDarker: #f8deeb;
  --main: #c41744;
  --mainLighter: #dd3655;
  --mainDarker: #810016;
  --grey: #a38f95;
  --greyDarker: #705c62;
  --contrasting: #58d0d2;
  --contrasting2: #9f9e60;

  --maxWidth: 1140px;
  --navHeight: 78px;
}

* {
  box-sizing: border-box;

  &:before, &:after {
    box-sizing: inherit;
  }
}

body {
  background-color: var(--brandDark);
  background-image:
    radial-gradient(ellipse closest-side at center, transparent 0, rgba(0, 0, 0, .6) 100%),
    url(/static/bg.png);
  font-family: 'Open Sans', sans-serif;
  font-weight: 400;
  color: var(--white);
  margin: 0;
  box-shadow: inset 0 0 40px #000;
  min-height: 100vh;
  min-height: 100dvh;

  /* Lets the footer fill the rest of the viewport on short pages */
  display: flex;
  flex-direction: column;
}

.view {
  width: 100%;
  max-width: var(--maxWidth);
  margin: 0 auto;
  padding: 2rem;
}

:focus {
  outline-color: var(--contrasting);
}
img {
  max-width: 100%;
}

[hidden] {
  display: none !important;
}

.flex-container {
  display: flex;
}

body:has(dialog:modal),
:root:not(.age-ok) body:has(age-gate dialog[open]) {
  overflow: hidden;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  grid-gap: 1rem;
  margin-top: 2rem;

  & img {
    max-width: 100%;
    display: block;
    border-radius: 0.125rem;
    transition: transform 100ms ease-out;
  }

  & a:hover img,
  & a:focus-visible img {
    transform: scale(1.1);
  }
}

@media (min-width: 820px) {
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}

h1, h2, h3, h4 {
  font-weight: 800;
  margin: 0 0 1rem 0;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: -1px;
  color: var(--contrasting2);
}

h1 {
  font-size: 2rem;

  & small {
    display: block;
    font-size: 1.2rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.205rem;
  }
}

p {
  margin: 0 0 1rem 0;
}

a {
  color: var(--main);
  text-decoration: none;
  font-weight: inherit;
  transition: all 100ms ease-out;

  &:hover {
    color: var(--mainLighter);
  }
}

button, [role="button"] {
  display: inline-flex;
  align-items: center;
  font-family: inherit;
  font-size: 1rem;
  color: inherit;
  cursor: pointer;
  background-color: var(--main);
  border-radius: 0.25rem;
  border: none;
  color: var(--white);
  padding: 0.5rem 1rem 0.75rem 1rem;
  margin: 0;
  text-decoration: none;
  box-shadow: inset 0 -0.25rem 0 var(--mainDarker);
  transition: all 100ms linear;

  &:not([disabled]):hover {
    background-color: var(--mainLighter);
    color: var(--whiteDarker);
    text-decoration: none;
    box-shadow: inset 0 0 0 var(--mainDarker);
    padding: 0.5rem 1rem 0.5rem 1rem;
    margin-top: 0.25rem;
  }

  &[disabled] {
    cursor: not-allowed;
    background-color: var(--grey);
    box-shadow: inset 0 -0.25rem 0 var(--greyDarker);
    opacity: 0.5;
  }

  &.large {
    font-size: 1.25rem;
    padding: 0.75rem 1.5rem 1rem 1.5rem;

    &:not([disabled]):hover {
      padding: 0.75rem 1.5rem 0.75rem 1.5rem;
    }
  }

  &.two-lines {
    flex-direction: column;
  }

  &.transparent {
    -webkit-appearance: none;
    border: none;
    padding: 0;
    background: transparent;
    color: inherit;
    box-shadow: none;
    cursor: pointer;

    &:hover {
      margin-top: 0;
      padding: 0;
    }
  }

  &.round {
    background-color: var(--main);
    border-radius: 50%;
    display: flex;
    padding: 0.5rem;
    box-shadow: none;

    &:not(:disabled):hover {
      background-color: var(--mainLighter);
      color: var(--whiteDarker);
      padding: 0.5rem;
      margin-top: 0;
    }
  }

  &.secondary {
    background-color: var(--grey);
    box-shadow: inset 0 -0.25rem 0 var(--greyDarker);

    & small {
      opacity: 0.9;
    }
  }

  & svg + span {
    padding-left: 0.5rem;
  }

  & small {
    font-size: 0.75em;
    color: var(--whiteDarker);
    opacity: 0.7;
  }
}

input, textarea {
  font-family: inherit;
  padding: 0.25rem 0.5rem;
  border-radius: 1rem;
  font-size: 0.8rem;
  background-color: color-mix(in srgb, var(--main) 20%, transparent);
  border: 0.125rem solid var(--mainDarker);
  color: var(--whiteDarker);
  -webkit-appearance: none;
}

.banner-links {
  & ul {
    list-style: none;
    margin: 2rem 0 0 0;
    padding: 0;
  }

  & li {
    padding: 0;
    margin: 0 0 2rem 0;
  }

  & img {
    max-width: 100%;
  }
}

.contact-form {
  max-width: 600px;
  margin: 0 auto;

  & form {
    display: grid;
    grid-template-columns: 100px 1fr;
    grid-gap: 1rem;
  }

  & label {
    text-align: right;
    padding-top: 6px;
  }

  & input, & textarea {
    font-size: 1rem;
  }

  & textarea {
    min-height: 8em;
  }
}
.home {
  & .pagination {
    margin-top: 1rem;
    display: flex;
    justify-content: center;
    
    & > * {
      display: flex;
      padding: 0.5rem;
    }

    & > span {
      opacity: 0.3;
    }
  }
}

dialog.modal {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: none;
  overflow: auto;
  overscroll-behavior: contain;
  color: inherit;
  background-color: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);

  &::backdrop {
    background: transparent;
  }

  & button.close {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 3;
    background-color: var(--main);
    border-radius: 50%;
    display: flex;
    padding: 0.5rem;

    &:not(:disabled):hover {
      background-color: var(--mainLighter);
      color: var(--whiteDarker);
      padding: 0.5rem;
    }
  }
}

.models {
  & ul {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(156px, 1fr));
    grid-gap: 1rem;
    list-style: none;
    padding: 0;
    text-align: center;
  }

  & li {
    --scale: 1;
    --size: 156px;

    & .avatar {
      display: inline-block;
      width: var(--size);
      height: var(--size);
      background-color: color-mix(in srgb, var(--main) 20%, transparent);
      background-image: url(/static/models.jpg);
      background-size: 1560px 3120px;
      border-radius: 0.25rem;
      box-shadow: inset 0 0 0 1px #000;
      background-position: calc(var(--x) * var(--scale) * -1px) calc(var(--y) * var(--scale) * -1px);
      transition: all 200ms ease-out;
    }

    /* The sprite's second row holds an alternate picture of each model */
    &:hover .avatar,
    &:focus-within .avatar {
      background-position: calc(var(--x) * var(--scale) * -1px) calc(var(--y) * var(--scale) * -1px - var(--size));
    }

    & .name {
      display: block;
    }
  }
}

@media (max-width: 400px) {
  .models {
    & ul {
      grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));

      & li {
        --scale: 0.5;
        --size: 78px;

        & .avatar {
          background-size: 780px 1560px;
        }
      }
    }
  }
}
.model-details {
  & header {
    display: flex;
    justify-content: space-between;
    background-color: color-mix(in srgb, var(--main) 20%, transparent);
    border-radius: 0.5rem;
    overflow: hidden;

    & h2 {
      margin: 0;

      & small {
        display: block;
        margin: 0.25rem 0 0 0;
        font-weight: 400;
        font-size: 1rem;
        color: var(--grey);
      }
    }

    & .title {
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      align-items: flex-start;
      padding: 1rem;
    }

    & .picture {
      display: flex;
      flex-direction: row;

      & > div {
        display: inline-block;
        width: 156px;
        height: 156px;
        background-image: url(/static/models.jpg);
        background-size: 1560px 3120px;
        background-position: calc(var(--x) * -1px) calc(var(--y) * -1px - 156px);
      }
    }
  }
}
.model-photos {
  margin-top: 2rem;
}

.main-navigation {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--main);
  color: var(--white);
  box-shadow: 0 -0.5rem 0.5rem -0.5rem rgba(0, 0, 0, 0.9);

  & a, & button.more {
    color: var(--white);
    text-decoration: none;
  }

  & ul {
    list-style: none;
    margin: 0 auto;
    padding: 0;
    display: flex;
    justify-content: stretch;
    max-width: var(--maxWidth);
  }

  & li {
    flex: 1 1 0;
    min-width: 0;
  }

  /* A fixed height, so the "More" menu can sit exactly on top of the bar */
  & li > a, & button.more {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: var(--navHeight);
    padding: 0 1rem;

    &:hover {
      background-color: var(--mainLighter);
      color: var(--whiteDarker);
    }

    &[aria-current="page"] {
      background-color: var(--mainLighter);
    }
  }

  & button.more {
    width: 100%;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
    line-height: inherit;

    &:not([disabled]):hover {
      background-color: var(--mainLighter);
      box-shadow: none;
      padding: 0 1rem;
      margin: 0;
    }
  }

  /* Five items have to fit on a narrow phone */
  @media (max-width: 480px) {
    & li > a, & button.more,
    & button.more:not([disabled]):hover {
      padding: 0 0.25rem;
      font-size: 0.9rem;
    }
  }
}

.popover {
  /* Pinned just above the bar's right-hand end, where the "More" button is. Not
     anchor-positioned: iOS Safari loses track of an anchor in a fixed bar as its
     toolbars collapse and expand, leaving the menu floating mid-screen. */
  position: fixed;
  inset: auto max(0px, (100% - var(--maxWidth)) / 2) var(--navHeight) auto;
  margin: 0;

  padding: 0;
  border: none;
  color: var(--white);
  background-color: var(--main);
  box-shadow: 0 0 0.5rem rgba(0, 0, 0, 0.9);

  & a {
    display: flex;
    flex-direction: row;
    justify-content: flex-end;
    align-items: center;
    padding: 1rem 3rem;

    &:hover {
      background-color: var(--mainLighter);
      color: var(--whiteDarker);
    }

    & svg {
      margin-left: 1rem;
    }
  }
}
photo-gallery {
  display: block;
}

/* Justified rows: each tile's width is proportional to its aspect ratio, so
   every tile in a row settles at the same height, with no layout JS.
   Longhands rather than the flex shorthand, which older WebKit mis-parses
   when fed a var(). */
.photo-grid {
  --row: 200px;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;

  /* Stops a short final row from stretching to full width */
  &::after {
    content: "";
    flex-grow: 1e9;
  }
}

.photo {
  position: relative;
  display: block;
  overflow: hidden;
  flex-grow: var(--r);
  flex-shrink: 1;
  flex-basis: calc(var(--r) * var(--row));
  border-radius: 0.125rem;

  /* The height comes from a percentage-padding spacer: Safari doesn't resolve
     aspect-ratio on a flex item whose main size is flexed */
  &::before {
    content: "";
    display: block;
    padding-top: calc(100% / var(--r, 1.5));
  }

  & img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 350ms ease, transform 100ms ease-out;

    &.ready {
      opacity: 1;
    }
  }

  &:hover img,
  &:focus-visible img {
    transform: scale(1.05);
  }

  & .badge {
    position: absolute;
    top: 0.25rem;
    left: 0.25rem;
    padding: 0 0.375rem;
    border-radius: 0.125rem;
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--white);
    background-color: var(--mainDarker);
  }
}

@media (max-width: 640px) {
  .photo-grid {
    --row: 140px;
    gap: 0.25rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .photo img {
    transition: none;
  }
}

.pswp__caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0.75rem;
  padding: 0 1rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--white);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

video-search:not(:defined) {
  display: none;
}

.search {
  display: block;

  & form {
    display: flex;
    align-items: stretch;
    margin-bottom: 1rem;

    & input {
      flex: 1;
      font-size: 1rem;
      border-top-right-radius: 0;
      border-bottom-right-radius: 0;
      margin: 0;
    }

    & button {
      margin-left: 0;
      border-top-left-radius: 0;
      border-bottom-left-radius: 0;
      border-top-right-radius: 1rem;
      border-bottom-right-radius: 1rem;
      padding: 0.25rem 1.25rem 0.25rem 1rem;
      box-shadow: none;

      &:not([disabled]):hover {
        padding: 0.25rem 1.25rem 0.25rem 1rem;
        margin-top: 0;
        box-shadow: none;
      }
    }
  }

  & .search-status {
    color: var(--grey);
    font-size: 0.9rem;
  }

  & .show-more {
    display: flex;
    margin: 1rem auto;
  }
}

.result {
  display: flex;
  text-align: left;
  font-size: 0.8rem;
  color: var(--white);
  background-color: color-mix(in srgb, var(--main) 20%, transparent);
  border-radius: 0.25rem;
  overflow: hidden;
  margin: 0 0 0.25rem 0;

  &:hover {
    color: var(--white);
    background-color: color-mix(in srgb, var(--main) 40%, transparent);
  }

  & .cover {
    width: 120px;
    min-width: 120px;
  }

  & img {
    max-width: 100%;
    display: block;
  }

  & h4 {
    margin: 0 0 0.25rem 0;
  }

  & .text {
    margin: 0.5rem 1rem;

    & p {
      margin: 0;
    }
  }

  & .excerpt {
    color: var(--grey);

    & mark {
      background: none;
      color: var(--mainLighter);
      font-weight: 800;
    }
  }
}

.site-header {
  width: 100%;
  max-width: var(--maxWidth);
  margin: 0 auto;
  padding: 2rem 2rem 0 2rem;

  & > div {
    background-image: url(/static/ballgag.png);
    background-repeat: no-repeat;
    background-position: left center;
    background-size: contain;
    height: 80px;
    display: flex;
    align-items: center;
    padding-left: 70px;
  }

  & h1 {
    margin: 0;
  }
}

@media screen and (max-width: 400px) {
  .site-header {

    & > div {
      background-position: center top;
      height: auto;
      background-size: 60px;
      padding: 90px 0 0 0;
    }

    & h1 {
      text-align: center;
      width: 100%;
      font-size: 1.75rem;

      & small {
        font-size: 1rem;
        text-align: center;
        letter-spacing: 0.1rem;
      }
    }
  }
}

.site-footer {
  flex-grow: 1;
  background-color: rgba(0, 0, 0, 0.4);

  & > div {
    max-width: var(--maxWidth);
    margin: 0 auto;
    padding: 2rem 2rem 8rem 2rem;
    font-size: 0.8rem;
    color: var(--greyDarker);
    text-align: center;
  }

  & nav {
    margin-top: 0.25rem;
  }

  & ul {
    list-style: none;
    padding: 0;
    margin: 0;
  }

  & li {
    display: inline-block;
  }

  & a {
    color: var(--grey);

    &:hover {
      color: var(--mainLighter);
    }
  }
}
.video-details {
  max-width: var(--maxWidth);
  margin: 0 auto;

  & > div {
    padding: 2rem 2rem 5rem 2rem;
  }

  & video {
    width: 100%;
    height: auto;
    display: flex;
  }

  .view & > div {
    padding: 2rem 0 0 0;
  }

  & .models {
    color: var(--whiteDarker);
  }

  & .specs {
    justify-content: space-between;
    font-size: 0.8rem;

    & span {
      color: var(--mainLighter);
    }
  }

  & .purchase-options {
    margin-top: 1rem;
    text-align: center;
    display: flex;
    flex-direction: column;

    & div {
      margin: 1rem auto 0 auto;
    }

    & .purchase-notice {
      display: inline-flex;
      align-items: center;
      gap: 0.5rem;
      margin: 1rem auto 0 auto;
      padding: 0.75rem 1rem;
      border-radius: 0.25rem;
      color: var(--whiteDarker);
      background-color: color-mix(in srgb, var(--main) 20%, transparent);
    }
  }
}

age-gate {
  display: contents;
}

.age-ok age-gate {
  display: none;
}

/* Also covers the page when opened non-modally (i.e. without JavaScript) */
dialog.age-gate {
  position: fixed;
  inset: 0;
  z-index: 10;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: none;
  overflow-y: auto;
  color: inherit;
  background-color: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);

  &::backdrop {
    background: transparent;
  }
}

.warning {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  min-height: 100%;
  padding: 5rem;
  text-align: center;
  background-color: rgba(0, 0, 0, 0.5);

  & .actions {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;

    & button {
      margin-bottom: 1rem;
    }
  }

  & aside {
    margin-top: 3rem;
    font-size: 0.9rem;
    color: var(--grey);

    & a {
      font-weight: 800;
    }
  }
}

@media (max-width: 400px) {
  .warning {
    padding: 3rem 1rem;
  }
}

.admin {
  & .counts {
    display: block;
    font-size: 0.8rem;
    color: var(--grey);

    & > span {
      display: block;
    }
  }

  & h3 {
    margin-top: 2rem;
  }

  & .badge {
    padding: 0 0.375rem;
    border-radius: 0.125rem;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0;
    vertical-align: middle;
    color: var(--white);
    background-color: var(--mainDarker);
  }

  & .meta {
    display: block;
    font-size: 0.8rem;
    color: var(--grey);
  }
}

/* The counts under a model's name in the page header */
.model-details.admin header h2 small {
  text-transform: none;
  letter-spacing: 0;

  & .counts {
    font-size: 1rem;
  }
}

.admin-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.5rem 1rem;
  list-style: none;
  padding: 0;
  margin: 0;

  & a, & li > div {
    display: block;
    color: var(--white);
  }

  & a:hover {
    color: var(--mainLighter);
  }

  & .meta a {
    display: inline;
    color: var(--main);
  }

  & .thumb {
    position: relative;
    display: block;
    overflow: hidden;
    margin-bottom: 0.375rem;
    border-radius: 0.125rem;
    background-color: color-mix(in srgb, var(--main) 20%, transparent);

    & img {
      display: block;
      width: 100%;
      height: 100%;
      object-fit: cover;
      transition: transform 100ms ease-out;
    }

    & .badge {
      position: absolute;
      top: 0.25rem;
      left: 0.25rem;
    }
  }

  & a:hover img,
  & a:focus-visible img {
    transform: scale(1.05);
  }

  & strong {
    display: block;
    font-size: 0.9rem;
  }

  /* Videos that aren't on the site can't be opened */
  & .unpublished .thumb img {
    opacity: 0.6;
  }
}

.admin-gallery .gallery-header {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1.5rem;

  & h2 {
    margin-bottom: 0.5rem;
  }

  & .meta {
    margin-bottom: 0.5rem;
  }

  & .description {
    max-width: 70ch;
  }
}

@media (max-width: 480px) {
  .admin-cards {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 1rem 0.75rem;
  }
}
