/*
 * Blink Desktop markup compatibility layer.
 * Load this file last. It maps the current static shell/runtime hooks onto the
 * Fluent component styles without coupling the core stylesheets to JS details.
 */

/* The desktop surface already excludes the taskbar; do not subtract it twice. */
.window-layer {
  inset: 0;
}

.app-window.is-maximized,
.app-window[data-state="maximized"] {
  inset: 0 !important;
}

/* Current WindowManager uses .is-open and toggles restore on the control. */
.app-window.is-open {
  animation: window-open var(--duration-slow) var(--ease-emphasized) both;
}

.window-control.is-restore .window-control-glyph--maximize::before {
  inset: 3px 1px 1px 3px;
  width: 8px;
  height: 8px;
  background: var(--surface-titlebar);
}

.window-control.is-restore .window-control-glyph--maximize::after {
  content: "";
  position: absolute;
  inset: 1px 3px 3px 1px;
  width: 8px;
  height: 8px;
  border: 1px solid currentColor;
  border-radius: 1px;
}

.desktop-shell.is-window-interacting {
  cursor: grabbing;
  user-select: none !important;
  -webkit-user-select: none !important;
}

.desktop-shell.is-window-interacting iframe {
  pointer-events: none;
}

/* Static-shell wallpaper and unobtrusive Blink signature. */
.desktop-wallpaper {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.wallpaper-ribbon,
.wallpaper-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(2px);
}

.wallpaper-ribbon--one {
  inset: 7% 9% -36% 34%;
  border: clamp(70px, 10vw, 170px) solid rgba(22, 139, 205, 0.13);
  transform: rotate(-22deg);
}

.wallpaper-ribbon--two {
  inset: -28% 27% 12% 37%;
  border: clamp(54px, 8vw, 130px) solid rgba(73, 209, 232, 0.09);
  transform: rotate(27deg);
}

.wallpaper-glow {
  inset: 20% 28% 18% 41%;
  background: rgba(113, 225, 241, 0.08);
  filter: blur(54px);
}

.desktop-brand {
  position: absolute;
  z-index: calc(var(--z-desktop) + 1);
  inset: auto 28px calc(var(--taskbar-total-height) + 28px) auto;
  display: grid;
  gap: 2px;
  max-width: min(320px, calc(100vw - 48px));
  padding: 0;
  border: 0;
  border-radius: 0;
  color: rgba(255, 255, 255, 0.42);
  background: transparent;
  box-shadow: none;
  font-family: "Segoe UI", "Segoe UI Variable", system-ui, sans-serif;
  font-size: 18px;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.25;
  text-align: left;
  text-shadow: none;
  opacity: 1;
  pointer-events: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  user-select: none;
}

.desktop-brand__wordmark {
  font-size: 18px;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.25;
  color: inherit;
}

.desktop-brand__edition {
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.3;
  color: inherit;
  opacity: 0.95;
}

.desktop-shell[data-theme="light"] .desktop-brand {
  color: rgba(22, 22, 22, 0.58);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.72);
}

/* Boot/shutdown markup aliases used by index.html. */
.boot-screen {
  grid-auto-flow: row;
  align-content: center;
  justify-items: center;
}

.boot-screen__message,
.boot-screen__status,
.boot-screen__wordmark {
  display: none;
}

.shutdown-overlay.is-visible,
.shutdown-overlay.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.shutdown-overlay:not(.is-visible):not(.is-open) {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.shutdown-overlay__content {
  gap: 48px;
}

.shutdown-overlay__message {
  margin-top: 8px;
  font-size: 20px;
  font-weight: 400;
  letter-spacing: 0.01em;
  color: rgba(255, 255, 255, 0.92);
}

.shutdown-spinner {
  position: relative;
  width: 48px;
  height: 48px;
}

/* Icon variants emitted by createAppIcon(). */
.app-icon__sheen {
  position: absolute;
  z-index: 1;
  inset: 1px;
  border-radius: inherit;
  background: linear-gradient(125deg, rgba(255, 255, 255, 0.17), transparent 43%);
  pointer-events: none;
}

.app-icon__mark {
  z-index: 2;
}

.app-icon--sim {
  --icon-color-a: #36bcbc;
  --icon-color-b: #087078;
}

.app-icon--sandbox {
  --icon-color-a: #70b85d;
  --icon-color-b: #3d6f34;
}

.app-icon--small {
  --icon-size: 32px;
  border-radius: 7px;
}

/* Current context-menu markup uses direct buttons and <hr>. */
.context-menu > button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 32px;
  gap: 12px;
  padding: 4px 9px 4px 34px;
  border-radius: 4px;
  color: var(--text-primary);
  text-align: left;
}

.context-menu > button:hover,
.context-menu > button:focus-visible {
  background: var(--surface-layer-hover);
}

.context-menu > button:active {
  background: var(--surface-layer-pressed);
}

.context-menu > hr {
  height: 1px;
  margin: 4px 7px;
  border: 0;
  background: var(--border-subtle);
}

.context-shortcut,
.context-note {
  margin-left: auto;
  color: var(--text-tertiary);
  font-size: 11px;
}

/* Placeholder and system-app content emitted by main.js. */
.placeholder-eyebrow {
  margin-bottom: 5px;
  color: #7cccf7;
  font-size: 11px;
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.placeholder-note {
  margin: 16px clamp(24px, 6vw, 58px) 0;
  padding: 12px 14px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-small);
  color: var(--text-secondary);
  background: var(--surface-card);
  font-size: var(--font-size-caption);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 24px;
  gap: 6px;
  padding: 3px 9px;
  border: 1px solid rgba(108, 203, 95, 0.3);
  border-radius: var(--radius-round);
  color: #a8e79f;
  background: rgba(76, 176, 72, 0.13);
  font-size: 11px;
  font-weight: var(--font-weight-medium);
}

.status-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(108, 203, 95, 0.12);
}

.about-facts {
  display: grid;
  width: min(520px, 100%);
  margin-top: 16px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-medium);
  background: var(--border-subtle);
  text-align: left;
}

.about-facts > * {
  display: grid;
  grid-template-columns: minmax(110px, 0.36fr) minmax(0, 1fr);
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface-card);
}

.about-facts dt {
  color: var(--text-secondary);
}

.about-facts dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.about-note {
  max-width: 52ch;
  margin-top: 18px;
  color: var(--text-secondary);
  font-size: var(--font-size-caption);
}

.settings-header {
  display: grid;
  gap: 5px;
}

.settings-header h1 {
  font-size: var(--font-size-display);
  font-weight: var(--font-weight-semibold);
  letter-spacing: -0.035em;
}

.settings-header p {
  color: var(--text-secondary);
}

.settings-options {
  display: grid;
  gap: 18px;
}

.settings-group__header {
  margin: 0 2px 8px;
  color: var(--text-secondary);
  font-size: var(--font-size-caption);
  font-weight: var(--font-weight-semibold);
}

.settings-wallpapers {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.settings-wallpaper {
  display: grid;
  gap: 7px;
  min-width: 0;
  padding: 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-small);
  color: var(--text-secondary);
  background: transparent;
  font-size: var(--font-size-caption);
  text-align: left;
}

.settings-wallpaper:hover {
  background: var(--surface-layer-hover);
}

.settings-wallpaper.is-selected,
.settings-wallpaper[aria-pressed="true"] {
  border-color: var(--accent-border);
  color: var(--text-primary);
  background: var(--accent-subtle);
}

.wallpaper-swatch {
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-control);
  background:
    radial-gradient(ellipse at 62% 45%, rgba(65, 200, 235, 0.75), transparent 34%),
    linear-gradient(145deg, #061323, #0a5aa8);
  box-shadow: 0 3px 9px rgba(0, 0, 0, 0.25);
}

.wallpaper-swatch--midnight {
  background:
    radial-gradient(ellipse at 62% 45%, rgba(70, 110, 180, 0.62), transparent 34%),
    linear-gradient(145deg, #020711, #183b6d);
}

.wallpaper-swatch--sea-glass,
.wallpaper-swatch--sea {
  background:
    radial-gradient(ellipse at 62% 45%, rgba(78, 198, 190, 0.68), transparent 34%),
    linear-gradient(145deg, #03171d, #087484);
}

.settings-toggle-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  min-height: 56px;
  padding: 10px 14px;
  background: var(--surface-card);
}

.settings-toggle-row + .settings-toggle-row {
  border-top: 1px solid var(--border-subtle);
}

.recycle-panel {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 100%;
  gap: 12px;
  padding: 36px;
  color: var(--text-secondary);
  text-align: center;
}

.recycle-panel .app-icon {
  --icon-size: 72px;
  margin-bottom: 4px;
  border-radius: 18px;
}

.recycle-panel h1,
.recycle-panel h2 {
  color: var(--text-primary);
  font-size: var(--font-size-title);
  font-weight: var(--font-weight-medium);
}

.desktop-toast {
  /* Legacy alias — keep in sync with .win-toast styling in desktop.css */
  border-radius: 8px;
  animation: toast-in var(--duration-slow) var(--ease-emphasized) both;
}

/* Start-menu aliases for the current static shell. */
.start-menu > .start-search {
  width: auto;
  margin: 24px 34px 10px;
}

.start-search__icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin: 0 10px 0 13px;
  flex: 0 0 16px;
  border: 0;
  color: var(--text-secondary);
}

.start-search__icon::after {
  content: none;
}

.start-search:has(.start-search__icon)::before,
.start-search:has(.start-search__icon)::after {
  display: none;
}

.start-menu > .start-section {
  min-height: 0;
  margin: 0;
  padding: 10px 34px 20px;
  overflow-x: hidden;
  overflow-y: auto;
}

.start-app > span:not(.app-icon) {
  display: -webkit-box;
  max-width: 100%;
  overflow: hidden;
  font-size: 11px;
  line-height: 1.2;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.start-all {
  display: grid;
  gap: 2px;
  margin-top: 8px;
}

.start-list-app__copy > strong,
.start-list-app__copy > small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.start-list-app__copy > strong {
  font-size: var(--font-size-caption);
  font-weight: var(--font-weight-medium);
}

.start-list-app__copy > small {
  color: var(--text-secondary);
  font-size: 11px;
}

.start-all-button,
.start-back-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  gap: 6px;
  padding: 3px 10px;
  border: 1px solid var(--border-default);
  border-bottom-color: var(--border-strong);
  border-radius: var(--radius-control);
  color: var(--text-primary);
  background: var(--surface-layer);
  box-shadow: var(--shadow-control);
  font-size: var(--font-size-caption);
}

.start-all-button:hover,
.start-back-button:hover {
  background: var(--surface-layer-hover);
}

.start-footer {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 9px 38px;
  border-top: 1px solid var(--border-subtle);
  background: color-mix(in srgb, var(--text-primary) 8%, transparent);
}

.start-avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  overflow: hidden;
  border: 1px solid var(--border-default);
  border-radius: 50%;
  background: #526b7e;
  font-size: 12px;
  font-weight: var(--font-weight-semibold);
}

.start-power-wrap {
  position: relative;
}

.start-power {
  position: relative;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-control);
}

.start-power:hover,
.start-power[aria-expanded="true"] {
  background: var(--surface-layer-hover);
}

.power-glyph {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  color: currentColor;
}

.power-glyph::before,
.power-glyph::after {
  content: none;
}

.power-menu:not([hidden]) {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
  transition-delay: 0s;
}

.power-menu > button {
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: center;
  width: 100%;
  min-height: 34px;
  gap: 4px;
  padding: 5px 9px;
  border-radius: 4px;
  text-align: left;
}

.power-menu > button:hover,
.power-menu > button:focus-visible {
  background: var(--surface-layer-hover);
}

.power-menu > button:active {
  background: var(--surface-layer-pressed);
}

/* Taskbar aliases for index.html. */
.taskbar-start.is-active {
  border-color: var(--border-subtle);
  background: var(--surface-layer-hover);
}

.start-mark {
  width: 18px;
  height: 18px;
  background:
    linear-gradient(135deg, #4cc5f4, #0b74ce) 0 0 / 8px 8px no-repeat,
    linear-gradient(135deg, #4cc5f4, #0b74ce) 10px 0 / 8px 8px no-repeat,
    linear-gradient(135deg, #4cc5f4, #0b74ce) 0 10px / 8px 8px no-repeat,
    linear-gradient(135deg, #4cc5f4, #0b74ce) 10px 10px / 8px 8px no-repeat;
  filter: drop-shadow(0 1px 3px rgba(0, 71, 148, 0.36));
}

.start-mark > span {
  display: none;
}

.taskbar-start:has(.start-mark)::before {
  display: none;
}

.taskbar-app__label {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@media (max-width: 700px) {
  .start-menu > .start-search {
    margin: 18px 20px 8px;
  }

  .start-menu > .start-section {
    padding: 8px 20px 16px;
  }

  .settings-wallpapers {
    grid-template-columns: 1fr;
  }

  .about-facts > * {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}

@media (forced-colors: active) {
  .desktop-brand {
    border: 0;
    background: transparent;
    color: GrayText;
    box-shadow: none;
  }

  .desktop-toast {
    border: 1px solid CanvasText;
    background: Canvas;
    box-shadow: none;
  }

  .start-mark {
    background:
      linear-gradient(CanvasText, CanvasText) 0 0 / 8px 8px no-repeat,
      linear-gradient(CanvasText, CanvasText) 10px 0 / 8px 8px no-repeat,
      linear-gradient(CanvasText, CanvasText) 0 10px / 8px 8px no-repeat,
      linear-gradient(CanvasText, CanvasText) 10px 10px / 8px 8px no-repeat;
    filter: none;
  }
}
