/* @group Panels */

/* @group Shared */

#resize_panels {
  position: relative;
  box-sizing: border-box;
  width: 6px;
  background-color: var(--color-toolbar);
  border-inline-end: 1px solid var(--color-toolbar-border);
  border-inline-start: 1px solid var(--color-toolbar-border);
  cursor: ew-resize;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

#resize_panels::before {
  position: absolute;
  inset: 0 calc(var(--ui-space-3) * -1);
  content: '';
}

@media (pointer: fine) {
  #resize_panels::before {
    inset: 0 calc(var(--ui-space-1) * -1);
  }
}

#resize_panels.hidden {
  display: none;
}

#panels {
  color: var(--color-text);
  background-color: var(--color-toolbar);
}

#panels.hidden {
  display: none;
}

.panel:first-child {
  border-block-start-style: none;
}

/* A panel, and a section a screen builds inside its panel column with
   PanelHelper#panel_header (the website design tool's styles and script
   settings). Both have one row style and one hairline. */
.panel,
.panel_section {
  margin: 0;
  border-block-end: 1px solid var(--color-border-faint);
}

.panel_inner_border {
  position: relative;
  min-width: 165px;
  margin: 0;
  padding: var(--ui-panel-padding);
  overflow-x: hidden;
}

.panel_header {
  display: block;
  min-height: var(--ui-panel-header-height);
  white-space: normal;
  background-color: var(--color-toolbar);
  box-shadow: none;
}

/* The chevron takes the last column, 16px with its 12px glyph box at the end,
   after an optional mark (.panel_header_aside). */
:is(.panel_header button, summary.panel_header)::after {

  display: grid;
  place-items: center center;

  width: 12px;
  height: 100%;
  margin-inline-start: var(--ui-space-1);
  font: var(--ui-icon-weight) var(--ui-icon-size)/1 var(--ui-icon-font-family);
  transition: transform var(--ui-duration-feedback) var(--ui-ease-feedback);
  content: var(--ui-icon-angle-right) var(--ui-icon-alt,);

  transform: rotate(90deg);
}

:is(.panel_header button, summary.panel_header) {

  display: grid;
  align-items: center;

  grid-template-columns: min-content minmax(0, 1fr);
  gap: var(--ui-space-3);
  grid-auto-flow: column;
  grid-auto-columns: auto;
  width: 100%;
  min-width: 0;
  min-height: var(--ui-panel-header-height);
  padding: var(--ui-space-1) var(--ui-space-4);
  overflow: hidden;
  color: var(--color-panels-header-text-open);
  font-family: var(--ui-font-family);
  font-size: var(--ui-font-size-control);
  font-weight: var(--ui-weight-medium);
  line-height: var(--ui-line-height-control);
  text-align: start;
  background: none;
  border: none;
  cursor: pointer;
  appearance: none;
}

/* An inspector panel's row is the <summary> of its <details>, with no marker.
   Its heading (.panel_title) holds the icon and the title. So the row has two
   columns: the heading and the chevron. */
summary.panel_header {
  box-sizing: border-box;
  grid-template-columns: minmax(0, 1fr);
  list-style: none;
  background-color: var(--color-toolbar);
}

summary.panel_header::-webkit-details-marker {
  display: none;
}

.panel_title {
  display: flex;
  align-items: center;
  gap: var(--ui-space-3);
  min-width: 0;
  margin: 0;
  font: inherit;
  color: inherit;
}

/* Closed: a panel that is not open (or is fading closed, data-closing), and a
   section whose row's button says so (aria-expanded). */
:is(.panel:not([open]), .panel[data-closing]) > summary.panel_header,
.panel_header button[aria-expanded='false'] {
  color: var(--color-text-secondary);
}

:is(.panel:not([open]), .panel[data-closing]) > summary.panel_header:hover,
.panel_header button[aria-expanded='false']:hover,
:is(.panel_header button, summary.panel_header):hover {
  color: var(--color-panels-header-text-hover);
  background-color: var(--color-toolbar-hover);
}

/* DPG's panels: a closed panel's chevron points back to the sidebar edge (left)
   and turns down when open. */
:is(.panel:not([open]), .panel[data-closing]) > summary.panel_header::after,
.panel_header button[aria-expanded='false']::after {
  transform: rotate(180deg);
}

/* A section's content hides while its row is closed. Screens that animate
   the close keep each item's own display until the motion ends. */
.panel_section:has(> .panel_header > button[aria-expanded='false']) > :not(.panel_header) {
  display: none;
}

.panel_header_aside[hidden] {
  display: none;
}

:is(.panel_header button, .panel_title) .title {
  flex: 1;
  min-width: 0;
}

/* Inspector fields inside a panel section: a label, an optional description
   and the controls, one field gap apart and inset like a panel's content.
   Neighbouring gaps collapse, so hidden fields leave no space. */
.panel_field {
  margin: var(--ui-field-gap) 0;
}

.panel_section > .panel_field {
  padding-inline: var(--ui-panel-padding);
}

/* A label with small actions on its right (reset, make page specific). */
.panel_field_header {
  display: flex;
  align-items: center;
  gap: var(--ui-space-2);
  margin-block-end: var(--ui-label-gap);
}

.panel_field_header > .panel_field_label {
  flex: 1 1 auto;
  min-width: 0;
  margin-block-end: 0;
}

.panel_field_actions {
  display: flex;
  flex: 0 0 auto;
  gap: var(--ui-space-1);
}

.panel_field_action {
  --panel-field-action-icon: var(--ui-icon-ellipsis);

  display: inline-grid;
  box-sizing: border-box;
  width: var(--ui-toolbar-control);
  height: var(--ui-toolbar-control);
  margin: 0;
  padding: 0;
  color: var(--color-text-secondary);
  background: transparent;
  border: 0;
  border-radius: var(--ui-radius-control);
  cursor: pointer;
  place-items: center;
}

.panel_field_action::before {
  font: var(--ui-icon-weight) var(--ui-icon-size)/1 var(--ui-icon-font-family);
  content: var(--panel-field-action-icon) var(--ui-icon-alt,);
}

.panel_field_action[data-icon='reset'] {
  --panel-field-action-icon: var(--ui-icon-arrow-rotate-left);
}

.panel_field_action[data-icon='clone'] {
  --panel-field-action-icon: var(--ui-icon-clone);
}

.panel_field_action:hover {
  color: var(--color-text);
  background-color: var(--color-toolbar-hover);
}

.panel_field_action:focus-visible {
  outline: 2px solid var(--color-text);
  outline-offset: -2px;
}

@media (any-pointer: coarse) {
  .panel_field_action {
    width: var(--ui-touch-target);
    height: var(--ui-touch-target);
  }
}

/* The media a field applies to, before its label (phone, desktop, dark mode). */
.panel_field_label.icon::before {
  margin-inline-end: var(--ui-space-1);
  font-family: var(--ui-icon-font-family);
  font-weight: var(--ui-icon-weight);
}

.panel_field_label.icon.phone::before {
  content: var(--ui-icon-mobile) var(--ui-icon-alt,);
}

.panel_field_label.icon.phone_and_laptop::before {
  content: var(--ui-icon-laptop-mobile) var(--ui-icon-alt,);
}

.panel_field_label.icon.desktop::before {
  content: var(--ui-icon-desktop) var(--ui-icon-alt,);
}

.panel_field_label.icon.dark_mode::before {
  content: var(--ui-icon-moon) var(--ui-icon-alt,);
}

.panel_field_description:empty {
  display: none;
}

.panel_field_label {
  display: block;
  margin: 0 0 var(--ui-label-gap);
  color: var(--color-text);
  font-family: var(--ui-font-family);
  font-size: var(--ui-font-size-label);
  font-weight: var(--ui-weight-regular);
  font-style: normal;
  line-height: var(--ui-line-height-body);
}

.panel_field_description {
  margin: 0 0 var(--ui-label-gap);
  color: var(--color-text-secondary);
  font-family: var(--ui-font-family);
  font-size: var(--ui-font-size-small);
  font-weight: var(--ui-weight-regular);
  line-height: var(--ui-line-height-body);
}

.panel_field_controls > :is(input:not([type='checkbox'], [type='radio'], [type='range']), select, textarea) {
  margin-block-start: 0;
  margin-block-end: 0;
}

.panel_field_controls > * + :is(input:not([type='hidden']), select, textarea, div) {
  margin-block-start: var(--ui-label-gap);
}

/* A field the page in the preview does not use (the website design tool's
   inactive styles) keeps DPG's diagonal stripe. The stripe is drawn light
   enough that its label and description keep full text contrast. */
.panel_field.inactive {
  padding-block: var(--ui-space-2);
  background: repeating-linear-gradient(45deg, var(--color-inactive-pattern-one) 0 var(--ui-space-2), var(--color-panel-field-inactive-stripe) var(--ui-space-2) var(--ui-space-4));
}

@media (width >= 0) and (width <= 768px) {
  :is(.panel_header button, summary.panel_header) {
    gap: var(--ui-space-3);
    padding: var(--ui-space-1) var(--ui-panel-padding);
  }

  .panel_inner_border {
    margin-inline-end: 0;
    margin-inline-start: 0;
  }
}

#panels select {
  box-sizing: border-box;
  width: 100%;
}

#panels textarea {
  box-sizing: border-box;
  width: 100%;
  resize: vertical;
}

#panels input[type='text'],
#panels input[type='date'],
#panels input[type='datetime-local'],
#panels input[type='email'],
#panels input[type='range'],
#panels input[type='number'] {
  box-sizing: border-box;
  width: 100%;
}

#panels .check_box_group {
  display: flex;
  flex-flow: row nowrap;
  place-content: stretch flex-start;
  align-items: center;
}

#panels .switch_group label {
  width: 120px;
}

#panels:not(.panels-ready) .panel {
  visibility: hidden;
}

#panels.panels-restoring :is(.panel_header button, summary.panel_header)::after {
  transition: none;
}

#panels input.processing_width,
#panels input.processing_height {
  width: 35px;
}

#panels input.processing_height {
  margin-inline-start: var(--ui-space-1);
}

#panels .range_value {
  display: block;
  color: var(--color-text-secondary);
  font-size: var(--ui-font-size-small);
  text-align: end;
  font-variant-numeric: tabular-nums;
}

#panels input.overlay_offset_x {
  width: 35px;
}

#panels input.overlay_offset_y {
  width: 35px;
}

/* Labels wrap only between words (break-word never narrows a column), while
   long values such as file names and checksums may break anywhere. */
#panels th,
#panels td {
  padding: var(--ui-space-2);
  line-height: var(--ui-line-height-body);
  white-space: normal;
  overflow-wrap: break-word;
}

#panels .information .note {
  font-family: var(--ui-font-family);
  font-weight: var(--ui-weight-regular);
  font-style: italic;
}

#panels .buttons {
  margin-block-start: var(--ui-space-4);
  padding-block-start: 0;
  padding-inline-end: 0;
  text-align: end;
}

#panels table .drag_handle {
  background-image: url("/assets/tables/controls/drag_handle-fcfce398.svg");
  background-position: center center;
  background-repeat: no-repeat;
  background-size: 16px;
  cursor: move;
  touch-action: none;
}

#panels table .colour_picker {
  width: 40px;
}

#panels tr a:not(.button) {
  color: var(--color-panels-link);
}

#panels th {
  font-family: var(--ui-font-family);
  font-weight: var(--ui-weight-medium);
  text-align: start;
}

#panels tbody tr {
  border-block-start: 1px solid var(--color-border-subtle);
}

#panels tbody tr:hover td {
  background-color: var(--color-toolbar-hover);
}

#panels table td.content {
  width: 100% !important;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  overflow-wrap: anywhere;
}

#panels table.website_hosts td.content {
  width: 100% !important;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

#panels .link_button.negative {
  position: absolute;
  inset-block-start: var(--ui-space-4);
  inset-inline-end: 104px;
}

.cover_image_picker {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: var(--ui-space-4);
  margin-block: var(--ui-space-4);
}

.cover_image_preview {
  box-sizing: border-box;
  width: 118px;
  height: 118px;
  overflow: hidden;
  background-color: var(--color-image-background);
  background-image: var(--icon-drag-image-here);
  background-position: center;
  background-repeat: no-repeat;
  border: 1px solid var(--color-image-border);
  border-radius: var(--ui-radius-control);
}

.cover_image_preview .image_icon {
  width: 116px;
  height: 116px;
  border-style: none;
}

.cover_image_picker .select_tag_group {
  flex: 1 1 180px;
  min-width: 0;
  margin: 0;
}

.cover_image_picker select {
  width: 100%;
  min-height: var(--ui-touch-target);
}

/* @end */

/* @group Images */

/* @group List */

#new_image_version_details select,
#panels .image_version_details select {
  width: auto;
}

/* @end */

/* @group Review */

/* @group Video */

.poster_frame {
  display: flex;
  flex-flow: column nowrap;
  place-content: stretch flex-start;
  align-items: center;
  margin-block-end: var(--ui-space-4);
}

.poster_frame img {
  width: 100%;
  height: auto;
}

/* @end */

/* @end */

/* @end */

/* @end */

#panels .export_services .export_service {
  margin-block-end: var(--ui-space-4);
}

#panels .linked_ftp_accounts {
  display: grid;
  row-gap: var(--ui-space-1);
  margin-block-start: var(--ui-space-2);
}

/* Inspector drawer and shared keyboard affordances. */
:is(.panel_header button, summary.panel_header):focus-visible,
.panel_drawer_header button:focus-visible {
  outline: 2px solid var(--color-text);
  outline-offset: -3px;
}

.panel_drawer_header,
.panel_drawer_backdrop {
  display: none;
}

.panel_drawer_backdrop[hidden] {
  display: none;
}

@media (width <= 768px) {
  #panels.panel_drawer_open {
    z-index: var(--ui-layer-drawer);
    border-inline-start: 1px solid var(--color-border-faint);
    box-shadow: -8px 0 32px rgb(0 0 0 / 16%);
  }

  .panel_drawer_header {
    position: sticky;
    inset-block-start: 0;
    z-index: var(--ui-layer-overhang);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--ui-space-3);
    padding: var(--ui-space-2) var(--ui-space-4);
    color: var(--color-text);
    background: var(--color-toolbar);
    border-block-end: 1px solid var(--color-border-faint);
  }

  .panel_drawer_header > button {
    order: 3;
    min-height: var(--ui-touch-target);
    padding: 0 var(--ui-space-3);
    color: var(--color-text);
    font: inherit;
    background: var(--color-canvas);
    border: 1px solid var(--color-border-faint);
    border-radius: var(--ui-radius-control);
    cursor: pointer;
  }

  .panel_drawer_backdrop:not([hidden]) {
    position: absolute;
    inset: 0;
    z-index: var(--ui-layer-drawer-backdrop);
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    background: var(--color-dialog-backdrop);
    border: 0;
    animation: panel-drawer-fade var(--ui-duration-reveal) var(--ui-ease-reveal);
  }

  /* The drawer slides in from the edge it is docked to (transform and
     opacity only, so nothing else lays out). A state restored as the page
     loads shows at once. */
  #panels.panel_drawer_open:not(.panels-restoring) {
    animation: panel-drawer-in var(--ui-duration-reveal) var(--ui-ease-reveal);
  }
}

@keyframes panel-drawer-in {
  from {
    transform: translateX(100%);
  }
}

@keyframes panel-drawer-fade {
  from {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  :is(.panel_header button, summary.panel_header)::after {
    transition: none;
  }

  /* As specific as the rule that slides the drawer in, so it wins. */
  #panels.panel_drawer_open:not(.panels-restoring),
  .panel_drawer_backdrop:not([hidden]) {
    animation: none;
  }
}

.panel_drawer_actions {
  display: flex;
  align-items: center;
  order: 2;
  margin-inline-start: auto;
}

.panel_drawer_actions button {
  min-width: var(--ui-touch-target);
  min-height: var(--ui-touch-target);
}

.panel_drawer_actions button:focus-visible {
  outline: 2px solid var(--color-text);
  outline-offset: -3px;
}

#resize_panels:focus-visible {
  z-index: 1;
  outline: 2px solid var(--color-neutral);
  outline-offset: 2px;
}

.panels_resizing #resize_panels {
  z-index: 1;
  background-color: var(--color-neutral);
}

/* A pointer drag moves only the divider, over the faded page; the page lays
   out once, on release. Keyboard steps stay live. Pointer
   capture sends the drag to the divider, so the page keeps its pointer
   events (switching them off would restyle every element on the press). */
.panels_dragging #resize_panels {
  z-index: var(--ui-layer-overlay);
  will-change: transform;
}

.panels_dragging > #main,
.panels_dragging > #panels {
  opacity: 0.2;
}

.panels_resizing iframe {
  visibility: hidden;
}

/* A field description can locate its subject in a companion canvas. */
button.panel_field_description {
  display: block;
  inline-size: 100%;
  padding: 0;
  border: 0;
  background: none;
  text-align: start;
  white-space: normal;
  cursor: pointer;
}
button.panel_field_description:hover,
button.panel_field_description:focus-visible {
  text-decoration: underline;
}

button.panel_field_description > strong {
  display: block;
  color: var(--color-text);
  font-weight: var(--ui-weight-strong);
}
