/*
 * hydrushbad multiplayer codes (hyd-hydrushbad-play.js): the code panel (#hyd-hydrushbad-code) and the owner’s page
 * (#hyd-hydrushbad-codes). Both are the site’s own small window, as the unlock window is (hyd-hydrushbad.css): the email
 * window’s title bar, close box and body classes (hyd-personal-details.css, recoloured by hyd-theme.css), with only what
 * that file scopes to #email-manad repeated here, in the same theme tokens.
 */

:is(#hyd-hydrushbad-code, #hyd-hydrushbad-codes) {
  position: fixed;
  inset: 0;
  margin: auto;
  width: 380px;
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 24px);
  overflow: hidden;
  padding: 3px;
  border: 1px solid var(--desktop-rim, #765584);
  border-color: var(--metal-top, #e3cde9) var(--paper-edge, #765584) var(--paper-edge, #765584) var(--metal-top, #e3cde9);
  border-radius: 3px;
  background: var(--paper-surface, #291c33);
  box-shadow: 3px 5px #0008;
  color: var(--paper-text, #f2dfee);
  font-family: var(--desktop-font, Tahoma, sans-serif);
}

/* The owner’s page holds a list: wider, and as tall as it needs up to the screen. */
#hyd-hydrushbad-codes {
  width: 760px;
}

:is(#hyd-hydrushbad-code, #hyd-hydrushbad-codes)[open] {
  display: flex;
  flex-direction: column;
}

:is(#hyd-hydrushbad-code, #hyd-hydrushbad-codes) .personal-email-body h2 {
  font-size: 17px;
}

:is(#hyd-hydrushbad-code, #hyd-hydrushbad-codes) .personal-email-body h3 {
  margin: 0 0 6px;
  color: var(--paper-text, #f2dfee);
  font: 700 13px/1.3 var(--desktop-font, Tahoma, sans-serif);
}

:is(#hyd-hydrushbad-code, #hyd-hydrushbad-codes) .personal-email-body p {
  margin: 0 0 12px;
}

:is(#hyd-hydrushbad-code, #hyd-hydrushbad-codes) .personal-email-body p:empty,
:is(#hyd-hydrushbad-code, #hyd-hydrushbad-codes) .personal-email-body [hidden] {
  display: none;
}

:is(#hyd-hydrushbad-code, #hyd-hydrushbad-codes) :is(.hydrushbad-code-status, .hydrushbad-codes-status) {
  min-height: 1.5em;
  color: var(--paper-text, #f2dfee);
  overflow-wrap: anywhere;
}

:is(#hyd-hydrushbad-code, #hyd-hydrushbad-codes) :is(.hydrushbad-code-actions, .hydrushbad-code-ways) {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 12px;
}

/* Every button and both links look like the email window’s one button (.personal-email-body > button). */
:is(#hyd-hydrushbad-code, #hyd-hydrushbad-codes) .personal-email-body :is(button, .hydrushbad-code-ways a) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  border: 1px solid;
  border-color: var(--metal-top, #f6e9fa) var(--paper-edge, #735a83) var(--paper-edge, #735a83) var(--metal-top, #f6e9fa);
  border-radius: 4px;
  background: linear-gradient(var(--metal-top, #efe3f6), var(--metal-mid, #b396c6));
  color: var(--metal-ink, #2e1c3c);
  padding: 7px 12px;
  font: 12px var(--desktop-font, Tahoma, sans-serif);
  text-decoration: none;
  text-shadow: 0 1px #fff8;
  cursor: pointer;
}

:is(#hyd-hydrushbad-code, #hyd-hydrushbad-codes) .personal-email-body button[type='submit'] {
  font-weight: 700;
}

:is(#hyd-hydrushbad-code, #hyd-hydrushbad-codes) .personal-email-body button:disabled {
  opacity: 0.5;
  cursor: default;
}

/* The code window’s field and its show toggle beside it, on one line; each show toggle keeps its own width. */
#hyd-hydrushbad-code .hydrushbad-code-field {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  margin: 0 0 12px;
}

#hyd-hydrushbad-code .hydrushbad-code-field label {
  flex: 1;
  min-width: 0;
  margin: 0;
}

:is(#hyd-hydrushbad-code, #hyd-hydrushbad-codes) .personal-email-body .hydrushbad-reveal {
  flex: none;
}

/* How to get a code: under a rule, as the unlock window’s help is. */
#hyd-hydrushbad-code .hydrushbad-code-how {
  padding-top: 10px;
  border-top: 1px solid var(--paper-edge, #765584);
}

#hyd-hydrushbad-code .hydrushbad-code-how p {
  color: var(--paper-muted, #dec4e3);
}

/* The owner’s page: the make-a-code row, the new code shown once in large type, and the list. */
#hyd-hydrushbad-codes .hydrushbad-codes-make {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
  margin: 0 0 14px;
}

#hyd-hydrushbad-codes .hydrushbad-codes-make label {
  flex: 1 1 240px;
  margin: 0;
}

/* How long a code works: a native select beside the label field, drawn as the fields are (WebKit otherwise keeps a
   native-looking select at its own height, as the guestbook found), with its arrow in the text colour; it still opens
   the browser’s own list or the phone’s picker. */
#hyd-hydrushbad-codes .hydrushbad-codes-make .hydrushbad-codes-length {
  flex: 0 1 150px;
}

#hyd-hydrushbad-codes .hydrushbad-codes-length select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--paper-edge, #8a6b99);
  border-radius: 3px;
  padding: 8px 28px 8px 8px;
  background-color: var(--paper-inset, #190f22);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--paper-text, #f9e7f5) 50%),
    linear-gradient(135deg, var(--paper-text, #f9e7f5) 50%, transparent 50%);
  background-position:
    calc(100% - 14px) center,
    calc(100% - 10px) center;
  background-size:
    4px 4px,
    4px 4px;
  background-repeat: no-repeat;
  color: var(--paper-text, #f9e7f5);
  font: 13px/1.5 var(--desktop-font, Tahoma, sans-serif);
  cursor: pointer;
}

/* The password again, asked by the server before a make or cancel: a box in place, as the new code’s box is. */
#hyd-hydrushbad-codes .hydrushbad-codes-again {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
  margin: 0 0 16px;
  padding: 12px;
  border: 1px solid var(--paper-edge, #765584);
  border-radius: 3px;
  background: var(--paper-panel, #353239);
}

#hyd-hydrushbad-codes .hydrushbad-codes-again .hydrushbad-codes-again-line {
  flex: 1 0 100%;
  margin: 0;
}

#hyd-hydrushbad-codes .hydrushbad-codes-again label {
  flex: 1 1 240px;
  margin: 0;
}

#hyd-hydrushbad-codes .hydrushbad-codes-new {
  margin: 0 0 16px;
  padding: 12px;
  border: 1px solid var(--paper-edge, #765584);
  border-radius: 3px;
  background: var(--paper-panel, #353239);
}

#hyd-hydrushbad-codes .hydrushbad-codes-new .hydrushbad-codes-code {
  display: block;
  width: 100%;
  margin: 0 0 8px;
  padding: 8px 10px;
  font: 700 30px/1.2 var(--desktop-font, Tahoma, sans-serif);
  letter-spacing: 0.08em;
  text-align: center;
}

#hyd-hydrushbad-codes .hydrushbad-codes-new p {
  margin: 0 0 8px;
}

#hyd-hydrushbad-codes .hydrushbad-codes-new .hydrushbad-codes-until {
  margin: 8px 0 0;
  color: var(--paper-muted, #dec4e3);
}

#hyd-hydrushbad-codes .hydrushbad-codes-list {
  width: 100%;
  margin: 0 0 12px;
  border-collapse: collapse;
  font-size: 12px;
}

#hyd-hydrushbad-codes .hydrushbad-codes-list :is(th, td) {
  padding: 6px 8px;
  border-bottom: 1px solid var(--paper-edge, #765584);
  text-align: left;
  vertical-align: middle;
}

#hyd-hydrushbad-codes .hydrushbad-codes-list th {
  color: var(--paper-muted, #dec4e3);
  font-weight: 400;
}

#hyd-hydrushbad-codes .hydrushbad-codes-list td:first-child {
  overflow-wrap: anywhere;
}

/* the actions column needs no visible heading; its buttons say what they do */
#hyd-hydrushbad-codes .hydrushbad-codes-actions-head {
  width: 1px;
  font-size: 0;
}

#hyd-hydrushbad-codes .hydrushbad-codes-actions {
  white-space: nowrap;
}

#hyd-hydrushbad-codes .hydrushbad-codes-actions .hydrushbad-codes-ask {
  display: block;
  margin: 0 0 6px;
  white-space: normal;
}

#hyd-hydrushbad-codes .hydrushbad-codes-actions button + button {
  margin-left: 6px;
}

:is(#hyd-hydrushbad-code, #hyd-hydrushbad-codes) :focus-visible {
  outline: 2px solid var(--paper-accent, #efb7dd);
  outline-offset: 2px;
}

/* A phone: each code is a card of named lines, since six columns do not fit. */
@media (max-width: 620px) {
  #hyd-hydrushbad-codes .hydrushbad-codes-list thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  #hyd-hydrushbad-codes .hydrushbad-codes-list,
  #hyd-hydrushbad-codes .hydrushbad-codes-list :is(tbody, tr, td) {
    display: block;
    width: 100%;
  }

  #hyd-hydrushbad-codes .hydrushbad-codes-list tr {
    padding: 8px 0;
    border-bottom: 1px solid var(--paper-edge, #765584);
  }

  #hyd-hydrushbad-codes .hydrushbad-codes-list td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 3px 0;
    border: 0;
  }

  #hyd-hydrushbad-codes .hydrushbad-codes-list td::before {
    flex: none;
    color: var(--paper-muted, #dec4e3);
    content: attr(data-label);
  }

  #hyd-hydrushbad-codes .hydrushbad-codes-list td.hydrushbad-codes-actions {
    display: block;
    padding-top: 8px;
    white-space: normal;
  }

  #hyd-hydrushbad-codes .hydrushbad-codes-list td.hydrushbad-codes-actions::before {
    display: none;
  }

  #hyd-hydrushbad-codes .hydrushbad-codes-new .hydrushbad-codes-code {
    font-size: 24px;
  }
}

/* Touch and phones: 44 px controls, and 16 px fields so iOS Safari does not zoom in on them. */
@media (max-width: 620px), (any-pointer: coarse) {
  :is(#hyd-hydrushbad-code, #hyd-hydrushbad-codes) .personal-titlebar .personal-close {
    flex: none;
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
  }

  :is(#hyd-hydrushbad-code, #hyd-hydrushbad-codes) .personal-email-body :is(button, .hydrushbad-code-ways a) {
    min-height: 44px;
  }

  :is(#hyd-hydrushbad-code, #hyd-hydrushbad-codes) .personal-email-body :is(input:not(.hydrushbad-codes-code), select) {
    font-size: 16px;
  }

  #hyd-hydrushbad-codes .hydrushbad-codes-length select {
    min-height: 44px;
  }
}
