/*
 * Appearance: wallpapers, the Glass surface and the Appearance window (docs/appearance-sounds-eggs.md).
 *
 * Everything is drawn with CSS gradients. There are no image files, no animation (a wallpaper never moves, so reduced motion
 * needs nothing special) and nothing here applies unless <body> carries data-wallpaper or data-surface, which frame-boot.js and
 * appearance.js only set for a non-default choice. The default page is therefore exactly what shipped before.
 *
 * Contrast: text on the desktop itself (the brand, the header pill) is measured by tests/e2e/contrast.spec.js against every
 * colour stop. So every stop of a desktop wallpaper is pale in the light theme (relative luminance 0.84 or more, enough for
 * the muted text colour) and deep in the dark theme. The richer pictures sit on the page behind the laptop, where no text is.
 *
 * To add a wallpaper: see "How to add a wallpaper" in docs/appearance-sounds-eggs.md.
 */

/* ---------- Wallpaper values: --wp-desk is the desktop inside the screen, --wp-page the backdrop behind the laptop. ---------- */

body[data-wallpaper="dusk"], .apSwatch[data-wallpaper="dusk"] {
  --wp-desk: radial-gradient(ellipse 75% 65% at 88% 108%, #fff3d6 0%, #fdeede 38%, #f9e9ef 68%, #efe9f8 100%);
  --wp-page: radial-gradient(ellipse 60% 38% at 50% 100%, #ffd9a8 0%, #ffd9a800 100%), linear-gradient(180deg, #8d84c9 0%, #d99ab8 55%, #f7b992 100%);
}
body.dark[data-wallpaper="dusk"], body.dark .apSwatch[data-wallpaper="dusk"] {
  --wp-desk: radial-gradient(ellipse 75% 65% at 88% 108%, #3b2235 0%, #2a2140 58%, #1c1f26 100%);
  --wp-page: radial-gradient(ellipse 60% 38% at 50% 100%, #8a4a55 0%, #8a4a5500 100%), linear-gradient(180deg, #171a2e 0%, #2d2150 55%, #4a2a45 100%);
}

body[data-wallpaper="harbor"], .apSwatch[data-wallpaper="harbor"] {
  --wp-desk: linear-gradient(180deg, #eaf3f7 0%, #e6f1f8 52%, #dcedf2 100%);
  --wp-page: linear-gradient(180deg, #d9edf7 0%, #bfe0ee 44%, #5ea3c4 46%, #3f7fa3 100%);
}
body.dark[data-wallpaper="harbor"], body.dark .apSwatch[data-wallpaper="harbor"] {
  --wp-desk: linear-gradient(180deg, #1a1d24 0%, #10242e 58%, #14303a 100%);
  --wp-page: linear-gradient(180deg, #14232f 0%, #0f2f3e 44%, #12485c 46%, #0a2431 100%);
}

body[data-wallpaper="meadow"], .apSwatch[data-wallpaper="meadow"] {
  --wp-desk: radial-gradient(ellipse 70% 32% at 22% 112%, #e1f1de 0 96%, #e1f1de00 100%), linear-gradient(180deg, #eaf3f7 0%, #ecf4ea 100%);
  --wp-page: radial-gradient(ellipse 58% 52% at 10% 108%, #5fa14f 0 98%, #5fa14f00 100%), radial-gradient(ellipse 62% 58% at 92% 112%, #7db868 0 98%, #7db86800 100%), linear-gradient(180deg, #bfe0f1 0%, #e9f5f6 100%);
}
body.dark[data-wallpaper="meadow"], body.dark .apSwatch[data-wallpaper="meadow"] {
  --wp-desk: radial-gradient(ellipse 70% 32% at 22% 112%, #1f3d2a 0 96%, #1f3d2a00 100%), linear-gradient(180deg, #1a1d24 0%, #16301f 130%);
  --wp-page: radial-gradient(ellipse 58% 52% at 10% 108%, #1f4a2c 0 98%, #1f4a2c00 100%), radial-gradient(ellipse 62% 58% at 92% 112%, #2a5c36 0 98%, #2a5c3600 100%), linear-gradient(180deg, #0f1c2c 0%, #1b3a4c 100%);
}

body[data-wallpaper="slate"], .apSwatch[data-wallpaper="slate"] {
  --wp-desk: linear-gradient(135deg, #eef1f6 0%, #e7eaf0 50%, #eef0f4 100%);
  --wp-page: linear-gradient(135deg, #a7b2c4 0%, #7c8aa0 52%, #566379 100%);
}
body.dark[data-wallpaper="slate"], body.dark .apSwatch[data-wallpaper="slate"] {
  --wp-desk: linear-gradient(135deg, #232a38 0%, #1c1f26 50%, #2d3648 100%);
  --wp-page: linear-gradient(135deg, #3a4558 0%, #242b39 58%, #171b24 100%);
}

body[data-wallpaper="plain"], .apSwatch[data-wallpaper="plain"] {
  --wp-desk: linear-gradient(#f2f3f5, #f2f3f5);
  --wp-page: linear-gradient(#d9dde4, #d9dde4);
}
body.dark[data-wallpaper="plain"], body.dark .apSwatch[data-wallpaper="plain"] {
  --wp-desk: linear-gradient(#1a1d24, #1a1d24);
  --wp-page: linear-gradient(#12151b, #12151b);
}

/* The default, drawn the way it ships, only for the preview swatch. */
.apSwatch[data-wallpaper="default"] {
  --wp-desk: linear-gradient(var(--desktop-surface), var(--desktop-surface));
  --wp-page: radial-gradient(ellipse at 50% 8%, #f5f6f8, #c6cbd3 90%);
}
body.dark .apSwatch[data-wallpaper="default"] { --wp-page: radial-gradient(ellipse at 50% 8%, #414652, #171b24 90%); }

/* ---------- Applying a wallpaper (the selectors are more specific than the base rules on purpose) ---------- */

html body[data-wallpaper] #screenScroll { background-image: var(--wp-desk); background-repeat: no-repeat; background-size: 100% 100%; }
html body.framed[data-wallpaper], html body.dark.framed[data-wallpaper] { background: var(--wp-page); background-attachment: fixed; }

/* ---------- Glass: frosted window bars and menus, only where the browser can blur what is behind them ---------- */

@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  body[data-surface="glass"] .osWindow { background: transparent; border-color: color-mix(in srgb, var(--paper) 60%, transparent); }
  body[data-surface="glass"] .osWindow .winbody { background: var(--paper); }
  body[data-surface="glass"] .osWindow .winbar {
    background: color-mix(in srgb, var(--paper) 82%, transparent);
    -webkit-backdrop-filter: blur(18px) saturate(1.4);
    backdrop-filter: blur(18px) saturate(1.4);
    border-bottom-color: color-mix(in srgb, var(--line) 70%, transparent);
  }
  /* Only the title bars: they hold one line of dark-on-light (or light-on-dark) title text. Menus and lists carry small muted
     text, so they stay solid (a see-through menu over an unknown backdrop cannot be shown to pass AA). */
}

/* ---------- The Appearance window ---------- */

.v06-icon-appearance { background: linear-gradient(150deg, #e8799f, #6d5bc4); color: #fff; }

.apShell .apPanel { display: grid; gap: 20px; max-width: 540px; padding: 6px 22px 28px; }
/* The panel is the part that scrolls: .app5 hides its overflow, so without this the last settings could not be reached
   in a window shorter than the list (responsive audit R03). */
.apShell > .apPanel { flex: 1 1 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain; align-content: start; }
.apIntro { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.apGroup { border: 0; margin: 0; padding: 0; min-width: 0; }
.apLegend { display: block; padding: 0; margin: 0 0 10px; font-size: 14px; font-weight: 650; color: var(--ink); }
.apHint { margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.apChoices { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 12px; }
.apChoices-surface { grid-template-columns: repeat(2, minmax(112px, 160px)); }
.apChoice { position: relative; display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink); cursor: pointer; }
.apChoice input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.apSwatch, .apSwatchInner { pointer-events: none; }
.apSwatch { position: relative; display: block; height: 68px; overflow: hidden; border: 2px solid var(--line); border-radius: 10px; background: var(--wp-page); }
.apSwatchInner { position: absolute; inset: 16% 14% 0; border: 1px solid #00000026; border-bottom: 0; border-radius: 6px 6px 0 0; background-image: var(--wp-desk); }
.apChoice:hover .apSwatch { border-color: var(--muted); }
.apChoice input:checked + .apSwatch { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.apChoice input:checked + .apSwatch::after { content: "✓"; position: absolute; top: 4px; right: 5px; display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); color: var(--paper); font-size: 12px; font-weight: 700; line-height: 1; }
.apChoice input:focus-visible + .apSwatch { outline: 3px solid var(--accent); outline-offset: 2px; }
.apName { font-weight: 600; }

/* The two surface previews: a little window over a colourful strip. */
.apSwatch-surface { background: linear-gradient(115deg, #7fb2dc 0%, #d996b6 55%, #f3b98d 100%); }
.apSwatch-surface .apSwatchInner { inset: 14% 14% 0; background: var(--paper); }
.apSwatch-surface .apSwatchInner::before { content: ""; position: absolute; inset: 0 0 auto; height: 11px; background: #d9dce2; border-bottom: 1px solid #0000001f; }
body.dark .apSwatch-surface .apSwatchInner::before { background: #3a3e48; }
.apSwatch-surface[data-surface="glass"] { background: linear-gradient(115deg, #3f86c8 0%, #d2587f 50%, #f2a45c 100%); }
.apSwatch-surface[data-surface="glass"] .apSwatchInner { background: linear-gradient(var(--paper), var(--paper)) 0 11px / 100% 100% no-repeat, transparent; }
.apSwatch-surface[data-surface="glass"] .apSwatchInner::before { background: #ffffff7a; border-bottom-color: #ffffff66; }
body.dark .apSwatch-surface[data-surface="glass"] .apSwatchInner::before { background: #ffffff33; }

.apSwitch { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 6px 14px 6px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink); font: inherit; font-size: 14px; text-align: left; cursor: pointer; }
.apSwitch:hover { border-color: var(--muted); }
.apSwitch:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.apTrack { position: relative; flex: none; width: 42px; height: 24px; border-radius: 12px; background: var(--muted); }
.apKnob { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--paper); transition: transform .15s ease; }
.apSwitch[aria-checked="true"] .apTrack { background: var(--accent); }
.apSwitch[aria-checked="true"] .apKnob { transform: translateX(18px); }
.apSwitchLabel { font-weight: 600; }
.apSwitchState { margin-left: auto; font-weight: 650; }
.apStatus { min-height: 1.4em; margin: 0; color: var(--muted); font-size: 12px; }

@media (prefers-reduced-motion: reduce) { .apKnob { transition: none; } }
@media (max-width: 440px) { .apShell .apPanel { padding: 6px 14px 24px; } .apChoices { grid-template-columns: repeat(2, 1fr); } .apChoices-surface { grid-template-columns: repeat(2, 1fr); } }

/* Announcements that are not part of any window (the Konami "Arcade unlocked"). */
.osSr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
