/* ============================================================
   OSpress — Desktop
   ============================================================ */

/* ── Ad Slots ─────────────────────────────────────────────── */
.ospress-ad {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
/* Size variants */
.ospress-ad--size-leaderboard     { width: 728px; min-height: 90px;  max-width: 100%; }
.ospress-ad--size-rectangle       { width: 300px; min-height: 250px; max-width: 100%; }
.ospress-ad--size-large_rectangle { width: 336px; min-height: 280px; max-width: 100%; }
.ospress-ad--size-skyscraper      { width: 160px; min-height: 600px; max-width: 100%; }
/* full_width: truly fill the available column; min-height prevents collapse
   when a responsive ad is still loading or returns empty */
.ospress-ad--size-full_width      { width: 100%;  height: auto; min-height: 90px; }
.ospress-ad--size-half_width      { width: 50%;   height: auto; max-width: 100%; }
/* Centering wrapper for fixed-width ads */
.ospress-ad--size-leaderboard,
.ospress-ad--size-rectangle,
.ospress-ad--size-large_rectangle,
.ospress-ad--size-skyscraper {
  margin-inline: auto;
}
/* Spacing based on position */
.ospress-ad--header_banner,
.ospress-ad--footer_banner        { padding: 8px 0; }
.ospress-ad--before_title,
.ospress-ad--before_content,
.ospress-ad--after_content,
.ospress-ad--after_comments,
.ospress-ad--in_content,
.ospress-ad--archive_top,
.ospress-ad--search_top,
.ospress-ad--archive_bottom       { margin: 16px 0; }
.ospress-ad--sidebar_top,
.ospress-ad--sidebar_bottom       { margin: 12px 0; }
.ospress-ad--archive_between,
.ospress-ad--archive_between_2    { width: 100%; margin: 4px 0; }

/* Slots that live OUTSIDE .document__content (before_title, before_content,
   after_content, after_comments, archive_*) are direct flex children of
   .doc-primary which has no padding, so they naturally fill the column.
   Force-stretch them so they always span the full available width. */
.doc-primary > .ospress-ad,
.explorer__main-primary > .ospress-ad {
  width: 100%;
  max-width: 100%;
  align-self: stretch;
}

/* Ad slots inside .explorer__content (flex layout): always occupy a full row */
.explorer__content > .ospress-ad {
  flex: 0 0 100%;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* Ad slots inside .sw-archive-grid (CSS grid): span all columns */
.sw-archive-grid > .ospress-ad {
  grid-column: 1 / -1;
  width: 100%;
  max-width: 100%;
}
/* AdSense / generic iframe children: allow free sizing */
.ospress-ad ins,
.ospress-ad iframe {
  display: block;
  width: 100%;
  max-width: 100%;
}



/* ── CSS Variables ───────────────────────────────────────── */
:root {
  /* Accent */
  --ospress-accent:       #0067C0;
  --ospress-accent-hover: #1976D2;
  --ospress-accent-light: #60CDFF;

  /* Desktop / Taskbar / Overlays — always dark */
  --ospress-bg:            #0d1117;
  --ospress-surface:       rgba(255,255,255,0.07);
  --ospress-surface-solid: rgba(28,28,42,0.95);
  --ospress-text:          #f0f0f0;
  --ospress-text-muted:    #9aa0b0;
  --ospress-border:        rgba(255,255,255,0.12);
  --ospress-shadow:        0 8px 32px rgba(0,0,0,0.55), 0 2px 8px rgba(0,0,0,0.3);

  /* Window chrome — LIGHT by default (Windows 11 light mode) */
  --win-surf:        rgba(251,253,255,0.88);
  --win-surf-solid:  #f3f6fc;
  --win-titlebar:    rgba(238,243,252,0.96);
  --win-toolbar:     rgba(246,249,255,0.9);
  --win-border:      rgba(0,0,0,0.10);
  --win-shadow:      0 8px 32px rgba(0,0,0,0.20), 0 2px 8px rgba(0,0,0,0.10);
  --win-text:        #1a1a2e;
  --win-text-muted:  #5a6070;
  --win-hover:       rgba(0,103,192,0.09);
  --win-selected:    rgba(0,103,192,0.14);
  --win-scrollbar:   rgba(0,0,0,0.15);
  --win-input-bg:    rgba(255,255,255,0.95);
  --win-focus-ring:  rgba(0,103,192,0.35);
  --win-link-color:   #0067C0;
  --win-link-visited: #5C2D91;

  /* Layout */
  --ospress-radius:    8px;
  --ospress-radius-lg: 12px;
  --taskbar-h:         48px;
  --taskbar-side-w:    64px;
  --icon-size-small:   64px;
  --icon-size-medium:  88px;
  --icon-size-large:   112px;

  /* Wallpaper gradient — overridable via Customizer */
  --wallpaper-from: #0a2a6e;
  --wallpaper-to:   #003f6b;
}

/* Dark mode — windows go dark too */
@media (prefers-color-scheme: dark) {
  :root {
    --win-surf:       rgba(30,30,46,0.93);
    --win-surf-solid: #1c1c2e;
    --win-titlebar:   rgba(38,38,56,0.97);
    --win-toolbar:    rgba(32,32,50,0.9);
    --win-border:     rgba(255,255,255,0.10);
    --win-shadow:     0 8px 32px rgba(0,0,0,0.55), 0 2px 8px rgba(0,0,0,0.3);
    --win-text:       #e8eaf0;
    --win-text-muted: #8891a0;
    --win-hover:      rgba(255,255,255,0.08);
    --win-selected:   rgba(0,103,192,0.24);
    --win-scrollbar:  rgba(255,255,255,0.14);
    --win-input-bg:   rgba(255,255,255,0.08);
    --win-focus-ring: rgba(96,205,255,0.4);
    --win-link-color:   var(--ospress-accent-light);
    --win-link-visited: #C5A6FA;
  }
}

/* Manual overrides via JS toggle */
[data-theme="light"] {
  --win-surf:       rgba(251,253,255,0.88);
  --win-surf-solid: #f3f6fc;
  --win-titlebar:   rgba(238,243,252,0.96);
  --win-toolbar:    rgba(246,249,255,0.9);
  --win-border:     rgba(0,0,0,0.10);
  --win-shadow:     0 8px 32px rgba(0,0,0,0.20), 0 2px 8px rgba(0,0,0,0.10);
  --win-text:       #1a1a2e;
  --win-text-muted: #5a6070;
  --win-hover:      rgba(0,103,192,0.09);
  --win-selected:   rgba(0,103,192,0.14);
  --win-scrollbar:  rgba(0,0,0,0.15);
  --win-input-bg:   rgba(255,255,255,0.95);
  --win-focus-ring: rgba(0,103,192,0.35);
  --win-link-color:   #0067C0;
  --win-link-visited: #5C2D91;
}

[data-theme="dark"] {
  --win-surf:       rgba(30,30,46,0.93);
  --win-surf-solid: #1c1c2e;
  --win-titlebar:   rgba(38,38,56,0.97);
  --win-toolbar:    rgba(32,32,50,0.9);
  --win-border:     rgba(255,255,255,0.10);
  --win-shadow:     0 8px 32px rgba(0,0,0,0.55), 0 2px 8px rgba(0,0,0,0.3);
  --win-text:       #e8eaf0;
  --win-text-muted: #8891a0;
  --win-hover:      rgba(255,255,255,0.08);
  --win-selected:   rgba(0,103,192,0.24);
  --win-scrollbar:  rgba(255,255,255,0.14);
  --win-input-bg:   rgba(255,255,255,0.08);
  --win-focus-ring: rgba(96,205,255,0.4);
  --win-link-color:   var(--ospress-accent-light);
  --win-link-visited: #C5A6FA;
}

html, body {
  margin: 0; padding: 0;
  width: 100%; height: 100%;
  font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  color: var(--ospress-text);
  overflow: hidden;
}

.ospress-body {
  background: #000;
  display: flex;
  flex-direction: column;
}

.ospress-root {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* ── Wallpaper ────────────────────────────────────────────── */
.wallpaper {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: linear-gradient(135deg, var(--wallpaper-from) 0%, #1565c0 30%, #0d47a1 55%, #006494 75%, var(--wallpaper-to) 100%);
  background-size: cover;
  background-position: center;
}

.wallpaper::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 28% 65%, rgba(96,205,255,0.20) 0%, transparent 70%),
    radial-gradient(ellipse 45% 60% at 78% 28%, rgba(0,120,220,0.22) 0%, transparent 70%);
  z-index: 1;
}

.wallpaper::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 1440 900' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0,650 Q360,480 720,560 T1440,420 L1440,900 L0,900Z' fill='rgba(255,255,255,0.035)'/%3E%3Cpath d='M0,700 Q400,550 800,620 T1440,500 L1440,900 L0,900Z' fill='rgba(255,255,255,0.025)'/%3E%3C/svg%3E");
  background-size: cover;
}

/* ── Desktop ──────────────────────────────────────────── */
.desktop {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 1;  pointer-events: all; /* inherit none from .ospress-main, override here */}

/* Taskbar position classes shift desktop inset */
.ospress-taskbar--bottom .desktop {
  bottom: var(--taskbar-h);
}
.ospress-taskbar--top .desktop {
  top: var(--taskbar-h);
}
.ospress-taskbar--left .desktop {
  left: var(--taskbar-side-w);
}
.ospress-taskbar--right .desktop {
  right: var(--taskbar-side-w);
}

/* ── Desktop Logo / Favicon Watermark ────────────────── */
.desktop__logo {
  position: absolute;
  bottom: 50%;
  right: 50%;
  transform: translate(50%, 50%);
  z-index: 3; 
  width: 100px;
  height: 100px;
  opacity: 0.55;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.4));
}
.desktop__logo img {
  width: 100px;
  height: 100px;
  object-fit: contain;
  border-radius: 4px;
}

/* ── Desktop Grid ─────────────────────────────────────── */
.desktop__grid {
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 8px;
  padding: 16px;
  height: 100%;
  overflow: hidden;
}

/* ── Desktop Icon ─────────────────────────────────────── */
.desktop-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: var(--icon-size-medium);
  padding: 8px 4px 6px;
  border-radius: var(--ospress-radius);
  cursor: pointer;
  transition: background 0.15s ease;
  position: relative;
  user-select: none;
  outline: none;
  /* when rendered as <a> tag */
  text-decoration: none;
  color: inherit;
}

.desktop-icon:hover,
.desktop-icon:focus-visible {
  background: rgba(255,255,255,0.1);
}

.desktop-icon:active {
  background: rgba(255,255,255,0.18);
}

.desktop-icon.selected {
  background: rgba(0,103,192,0.28);
  outline: 2px solid var(--ospress-accent);
}

.ospress-icons--small  .desktop-icon { width: var(--icon-size-small); }
.ospress-icons--large  .desktop-icon { width: var(--icon-size-large); }

.desktop-icon__graphic {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
}

.desktop-icon__badge {
  position: absolute;
  top: 4px;
  left: 4px;
  font-size: 18px;
  line-height: 1;
  pointer-events: none;
}

.desktop-icon__folder-svg {
  width: 48px;
  height: 40px;
  flex-shrink: 0;
  display: block;
}

.desktop-icon__file-svg {
  width: 40px;
  height: 40px;
  color: #ccc;
}

.desktop-icon__thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 4px;
}

.desktop-icon__label {
  font-size: 11px;
  text-align: center;
  line-height: 1.3;
  max-width: 100%;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--win-text);
}

.desktop-icon__label.always-white {
  color: #fff !important;
}

.desktop-icon__count.always-white {
  color: #fff !important;
}

.desktop-icon__count {
  position: absolute;
  top: 2px;
  right: 2px;
  background: var(--ospress-accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}
/* ── Desktop Widget (Recent Posts card) ───────────────── */
.desktop-widget {
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 300px;
  background: var(--win-surf);
  backdrop-filter: blur(32px) saturate(180%);
  -webkit-backdrop-filter: blur(32px) saturate(180%);
  border: 1px solid var(--win-border);
  border-radius: var(--ospress-radius-lg);
  box-shadow: var(--win-shadow);
  overflow: hidden;
  z-index: 50;
  color: var(--win-text);
  transition: opacity 0.2s, transform 0.2s;
}
.desktop-widget.is-hidden { display: none; opacity: 0; pointer-events: none; transform: scale(0.95); }

.desktop-widget__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px 8px;
  background: var(--win-titlebar);
  border-bottom: 1px solid var(--win-border);
  gap: 8px;
}

.desktop-widget__title {
  font-size: 12px;
  font-weight: 600;
  color: var(--win-text);
  display: flex;
  align-items: center;
  gap: 6px;
}

.desktop-widget__close {
  width: 22px;
  height: 22px;
  background: none;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--win-text-muted);
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
  font-size: 14px;
  line-height: 1;
}
.desktop-widget__close:hover { background: #c42b1c; color: #fff; }

.desktop-widget__list {
  list-style: none;
  margin: 0;
  padding: 4px 0;
}
.desktop-widget__item { border-bottom: 1px solid var(--win-border); }
.desktop-widget__item:last-child { border-bottom: 0; }

.desktop-widget__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  text-decoration: none;
  transition: background 0.12s;
  cursor: pointer;
}
.desktop-widget__link:hover { background: var(--win-hover); }

.desktop-widget__thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}

.desktop-widget__thumb-icon {
  width: 40px;
  height: 40px;
  background: var(--win-hover);
  border-radius: 6px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--win-text-muted);
}

.desktop-widget__info  { flex: 1; min-width: 0; }
.desktop-widget__post-title {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--win-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.desktop-widget__date {
  display: block;
  font-size: 10px;
  color: var(--win-text-muted);
  margin-top: 2px;
}

.desktop-widget__footer {
  display: block;
  text-align: center;
  padding: 7px 12px;
  font-size: 11px;
  color: var(--ospress-accent);
  text-decoration: none;
  border-top: 1px solid var(--win-border);
  background: var(--win-toolbar);
  transition: background 0.12s;
}
.desktop-widget__footer:hover { background: var(--win-hover); }
/* ── Toast notifications ──────────────────────────────── */
.desktop__toasts {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.ospress-taskbar--top .desktop__toasts {
  top: calc(var(--taskbar-h) + 16px);
}

.toast {
  background: var(--ospress-surface-solid);
  border: 1px solid var(--ospress-border);
  border-radius: var(--ospress-radius-lg);
  padding: 12px 16px;
  min-width: 260px;
  max-width: 360px;
  box-shadow: var(--ospress-shadow);
  pointer-events: all;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  animation: toast-in 0.3s ease;
}

.toast.hiding {
  animation: toast-out 0.25s ease forwards;
}

@keyframes toast-in  { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toast-out { to   { opacity: 0; transform: translateX(40px); } }

.toast__thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.toast__icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ospress-accent);
  flex-shrink: 0;
}

.toast__body { flex: 1; overflow: hidden; }
.toast__title { font-weight: 600; font-size: 13px; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toast__time  { font-size: 11px; color: var(--ospress-text-muted); }

.toast__close {
  background: none;
  border: none;
  color: var(--ospress-text-muted);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
}

/* ── Utility Buttons ──────────────────────────────────── */
.os-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--ospress-radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s;
  text-decoration: none;
}

.os-btn--primary {
  background: var(--ospress-accent);
  color: #fff;
}
.os-btn--primary:hover { background: var(--ospress-accent-hover); }

.os-btn--secondary {
  background: rgba(255,255,255,0.1);
  color: var(--ospress-text);
  border-color: var(--ospress-border);
}
.os-btn--secondary:hover { background: rgba(255,255,255,0.16); }

/* ── Folder Tree ──────────────────────────────────────── */
.folder-tree { list-style: none; margin: 0; padding: 0; }
.folder-tree__children { list-style: none; margin: 0; padding: 0; }
.folder-tree__item { margin: 0; }
.folder-tree__link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 4px;
  text-decoration: none;
  color: var(--ospress-text);
  transition: background 0.12s;
}
.folder-tree__link:hover { background: rgba(255,255,255,0.08); }
.folder-tree__badge { font-size: 14px; }
.folder-tree__name  { font-size: 13px; }
.folder-tree__count { font-size: 11px; color: var(--ospress-text-muted); }

/* ── Main area ─────────────────────────────────────────── */
.ospress-main {
  position: absolute;
  inset: 0;
  pointer-events: none; /* windows above handle their own events */
}

.ospress-main > .os-window {
  pointer-events: all;
}

/* ── Software Shortcut Icon ───────────────────────────── */
.desktop-icon--shortcut .desktop-icon__thumb {
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.32);
}

.desktop-icon__app-placeholder {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Shortcut arrow: small dark box with bent arrow, bottom-left of graphic */
.desktop-icon__shortcut-arrow {
  position: absolute;
  bottom: -1px;
  left: -1px;
  line-height: 0;
  pointer-events: none;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4));
}

/* ── Desktop Free-Placement (drag) ────────────────────── */

/* Applied by desktop-drag.js when any icon has been dragged */
#desktop-grid.is-free-layout {
  display: block;   /* override flex */
  position: relative;
}

#desktop-grid.is-free-layout .desktop-icon {
  position: absolute;
}

/* Icon being actively dragged */
.desktop-icon.is-dragging {
  opacity: 0.85;
  z-index: 9999 !important;
  cursor: grabbing !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  outline: 2px solid rgba(255,255,255,0.6);
  border-radius: var(--ospress-radius);
}
