:host(:not(:is([hydrated], .hydrated))) {
  @apply not-hydrated;
}


mds-button,
mds-icon,
mds-text {
  &:not(:is([hydrated], .hydrated)) {
    @apply not-hydrated;
  }
}


/**
 * @prop --mds-url-view-background: Public. Background color of the URL view container.
 * @prop --mds-url-view-color: Public. Text color used inside the URL view.
 * @prop --mds-url-view-radius: Public. Border-radius applied to the URL view container.
 * @prop --mds-url-view-header-shadow: Box-shadow applied to the header area of the URL view.
 * @prop --mds-url-view-shadow: Public. Box-shadow applied to the entire URL view container.
 */

/* ❌ Not supported

@property --mds-url-view-header-shadow {
  inherits: false;
  initial-value: var(--shadow-sm-sharp);
  syntax: "<box-shadow>";
}

@property --mds-url-view-shadow {
  inherits: false;
  initial-value: var(--shadow-lg);
  syntax: "<box-shadow>";
}
*/

:host {
  --mds-url-view-transition-duration: var(--duration-200, 200ms);
  --private-url-view-transition-duration: var(--mds-url-view-transition-duration);

  /* stylelint-disable-next-line length-zero-no-unit */
  --mds-modal-custom-window-distance: 0px;
  --mds-url-view-background: rgb(var(--magma-wash-soft, var(--tone-neutral-10, 237 237 237)));
  --mds-url-view-color: rgb(var(--magma-text-default, var(--text-neutral-default, 5 5 5)));
  --mds-url-view-radius: var(--magma-radius-md, var(--radius-squircle-md, 20px));
  --mds-url-view-header-shadow: var(--shadow-sm-sharp, 0 0 1px 1px rgb(0 0 0 / 0.06), 0 1px 3px 0 rgb(0 0 0 / 0.1));
  --mds-url-view-shadow: var(--shadow-lg, 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1));

  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  height: 100vh;
  margin: 0;
  padding: --spacing(400);
}

.window {
  @apply ease-out;

  background-color: var(--mds-url-view-background, rgb(var(--magma-wash-soft, var(--tone-neutral-10, 237 237 237))));
  border-radius: var(--mds-url-view-radius, var(--magma-radius-md, var(--radius-squircle-md, 20px)));
  box-shadow: var(--mds-url-view-shadow);
  corner-shape: var(--magma-corner-shape, squircle);
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  overflow: hidden;
  transition-duration: var(--private-url-view-transition-duration);
  transition-property: background-color, box-shadow;
  width: 100%;
}

.header {
  @apply ease-out;

  align-items: center;
  background-color: var(--mds-url-view-background, rgb(var(--magma-wash-soft, var(--tone-neutral-10, 237 237 237))));
  box-shadow: var(--mds-url-view-header-shadow);
  color: var(--mds-url-view-color, rgb(var(--magma-text-default, var(--text-neutral-default, 5 5 5))));
  display: flex;
  flex-shrink: 0;
  gap: --spacing(200);
  justify-content: space-between;
  padding: --spacing(200);
  position: relative;
  transition-duration: var(--private-url-view-transition-duration);
  transition-property: background-color, box-shadow;
}

.title {
  @apply truncate;

  flex-grow: 1;
  min-width: 0;
  text-align: center;
}

.window-icon {
  fill: var(--mds-url-view-color, rgb(var(--magma-text-default, var(--text-neutral-default, 5 5 5))));
  flex-shrink: 0;
}

.button-close {
  cursor: pointer;
  fill: var(--mds-url-view-color, rgb(var(--magma-text-default, var(--text-neutral-default, 5 5 5))));
}

.iframe {
  border: 0;
  flex-grow: 1;
  margin: 0;
  padding: 0;
  width: 100%;
}

/* Motion, held back.
 *
 * Every component zeroes the private durations its own base CSS reads, which composes
 * with the public knobs - but that only reaches the declarations that read them. An audit
 * of the 52 sheets found 21 transitions in 15 components that did not: the host's own
 * transition in mds-button and mds-table, the focus ring of the input family, the tab
 * slider, the close button of mds-note. This reset reaches the whole shadow tree, which is
 * what the preference promises, and keeps reaching it when a declaration is added.
 *
 * Transitions only, on purpose. A keyframe animation is usually a loader, and a loader has
 * to keep saying "working": mds-spinner slows to 8s under reduced motion instead of
 * freezing, and a duration of nearly zero on an infinite animation would spin it out of
 * control instead of stopping it.
 *
 * 0.01ms rather than 0s, so a component that waits for its own transitionend still gets
 * one: mds-modal, mds-push-notification and mds-tree-item all listen for it, and a
 * transition of zero never fires it. */

/* stylelint-disable time-min-milliseconds -- the floor is there to keep a transition
   perceivable; the point of these two is that it is not. */

:host([pref-animation='reduce']),
:host([pref-animation='reduce']) *,
:host([pref-animation='reduce']) *::before,
:host([pref-animation='reduce']) *::after {
  transition-duration: 0.01ms !important;
}

@media (prefers-reduced-motion: reduce) {
  :host([pref-animation='system']),
  :host([pref-animation='system']) *,
  :host([pref-animation='system']) *::before,
  :host([pref-animation='system']) *::after,
  :host(:not([pref-animation])),
  :host(:not([pref-animation])) *,
  :host(:not([pref-animation])) *::before,
  :host(:not([pref-animation])) *::after {
    transition-duration: 0.01ms !important;
  }
}

/* stylelint-enable time-min-milliseconds */


/* Animation preference. The component mirrors the resolved mode from <html>
 * onto its host as pref-animation (see subscribePreference in @common/preference);
 * these plain shadow selectors then zero the private duration(s) the base CSS
 * reads. `reduce` always stops; `system` and no controller follow the OS via
 * @media; `no-preference` keeps the base value. Customization composes (the base
 * sets --private from the public token, this only overrides it when reduced). */

:host([pref-animation='reduce']) {
  --private-url-view-transition-duration: 0s;
}

@media (prefers-reduced-motion: reduce) {
  :host([pref-animation='system']),
  :host(:not([pref-animation])) {
    --private-url-view-transition-duration: 0s;
  }
}

/* Theme preference. The component reflects the resolved theme mode and scheme
 * from <html> onto its host as pref-mode + pref-theme-scheme (see
 * subscribePreference in @common/preference); these plain shadow selectors refine
 * for dark. `dark` is the explicit choice; `system` and no controller follow the
 * OS via @media; the scheme axis gates it. Cross-browser, no :host-context. */

:host([pref-mode='dark']:not([pref-theme-scheme='light'])),
:host([pref-theme-scheme='dark']) {
  --mds-url-view-shadow: var(--shadow-ring, 0 0 0 1px rgb(var(--tone-neutral-01, 5 5 5) / 0.3));
}

@media (prefers-color-scheme: dark) {
  :host([pref-mode='system']:not([pref-theme-scheme='light'])),
  :host(:not([pref-mode]):not([pref-theme-scheme='light'])) {
    --mds-url-view-shadow: var(--shadow-ring, 0 0 0 1px rgb(var(--tone-neutral-01, 5 5 5) / 0.3));
  }
}

/* Contrast preference. The component reflects the resolved mode from <html> onto
 * its host as pref-contrast (see subscribePreference in @common/preference); these
 * plain shadow selectors refine for high contrast. `more` is the explicit choice;
 * `system` and no controller follow the OS via @media. Cross-browser, no :host-context. */

:host([pref-contrast='more']) {
  --mds-url-view-shadow: var(--shadow-ring-2, 0 0 0 2px rgb(var(--tone-neutral-01, 5 5 5) / 0.3));
}

@media (prefers-contrast: more) {
  :host([pref-contrast='system']),
  :host(:not([pref-contrast])) {
    --mds-url-view-shadow: var(--shadow-ring-2, 0 0 0 2px rgb(var(--tone-neutral-01, 5 5 5) / 0.3));
  }
}

