/* Eden App Frame Styles */

/* Squircle container styling */
html {
  background: transparent;
  height: 100%;
  /* Ensure shadows aren't clipped by html bounds if we want them, 
       but for a frameless window filling the view, we typically clip. 
       However, if we want shadows, we need margin. 
       Assuming view fills window exactly, we just want content clipped. */
  overflow: hidden;
  border-radius: 20px;
  /* Force clip-path to cleanly cut background pixels in Electron views */
  clip-path: inset(0 round 20px);
  /* Composite layer promotion to help with anti-aliasing of rounded corners */
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  transform: translate3d(0, 0, 0);
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  border-radius: 20px;

  /* Inner border to help definition against dark backgrounds */
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);

  overflow: hidden;
  /* Apps should handle scrolling internally */
  box-sizing: border-box;

  /* Ensure body background is transparent to prevent canvas propagation */
  background-color: transparent;
}

/* Paint background on a layer that DOES NOT propagate to canvas, allowing clip-path to work */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--app-bg, var(--eden-color-bg-secondary));
  backdrop-filter: var(--app-glass, none);
  z-index: -1;
  pointer-events: none;
}

#eden-app-frame-overlay#eden-app-frame-overlay {
  all: revert;
  --eden-frame-fg: #333;
  --eden-frame-muted: #666;
  --eden-frame-glass: rgba(255, 255, 255, 0.7);
  --eden-frame-hover: rgba(0, 0, 0, 0.08);
  --eden-frame-shadow:
    0 2px 8px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  --eden-layout-bg: rgba(250, 251, 253, 0.94);
  --eden-layout-border: rgba(25, 30, 45, 0.11);
  --eden-layout-shadow: 0 18px 44px rgba(20, 24, 35, 0.2);
  --eden-layout-action-bg: rgba(255, 255, 255, 0.72);
  --eden-layout-action-shadow: 0 1px 3px rgba(20, 24, 35, 0.1);
  /* Now only set what we actually need */
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 40px;
  background: transparent;
  border-bottom: none;
  border-radius: 20px 20px 0 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 16px;
  user-select: none;
  z-index: 2147483647;
  -webkit-app-region: no-drag;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  pointer-events: auto;
  will-change: transform;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
    Cantarell, sans-serif;
  box-sizing: border-box;
}

#eden-app-frame-overlay.dark#eden-app-frame-overlay.dark {
  --eden-frame-fg: #fff;
  --eden-frame-muted: #aaa;
  --eden-frame-glass: rgba(40, 40, 40, 0.7);
  --eden-frame-hover: rgba(255, 255, 255, 0.12);
  --eden-frame-shadow:
    0 2px 8px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  --eden-layout-bg: rgba(30, 31, 36, 0.94);
  --eden-layout-border: rgba(255, 255, 255, 0.1);
  --eden-layout-shadow: 0 20px 50px rgba(0, 0, 0, 0.48);
  --eden-layout-action-bg: rgba(255, 255, 255, 0.09);
  --eden-layout-action-shadow: 0 1px 4px rgba(0, 0, 0, 0.23);
  background: transparent;
  border-bottom: none;
  color: #cccccc;
}

#eden-app-frame-overlay #eden-app-frame-title {
  all: revert;
  /* Now only set what we actually need */
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 14px;
  font-weight: 600;
  color: var(--eden-frame-fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: calc(100% - 200px);
  text-align: center;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
    Cantarell, sans-serif;
  line-height: 1;
  letter-spacing: -0.3px;
  pointer-events: none;
  background: var(--eden-frame-glass);
  backdrop-filter: blur(20px) saturate(180%);
  padding: 8px 16px;
  border-radius: 10px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  box-shadow: var(--eden-frame-shadow);
}

#eden-app-frame-overlay.eden-app-frame-tiled #eden-app-frame-title {
  pointer-events: auto;
}

#eden-app-frame-overlay #eden-app-frame-title:focus-visible {
  outline: 2px solid var(--eden-color-accent-primary, #5b7cfa);
  outline-offset: 2px;
}

#eden-app-frame-overlay #eden-app-frame-title-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#eden-app-frame-overlay .eden-app-frame-title-chevron {
  display: none;
  width: 14px;
  height: 14px;
  margin-left: 5px;
  flex: 0 0 auto;
  transform: translateY(-1px);
  transition:
    opacity 140ms ease,
    transform 180ms ease;
}

#eden-app-frame-overlay.eden-app-frame-tiled .eden-app-frame-title-chevron {
  display: block;
  opacity: 0.56;
}

#eden-app-frame-overlay
  #eden-app-frame-title[aria-expanded="true"]
  .eden-app-frame-title-chevron {
  transform: rotate(180deg) translateY(1px);
  opacity: 0.9;
}

#eden-app-frame-overlay #eden-tile-layout-compass[hidden] {
  display: none;
}

#eden-app-frame-overlay #eden-tile-layout-compass {
  all: revert;
  position: absolute;
  top: 43px;
  left: 50%;
  width: 228px;
  transform: translateX(-50%);
  box-sizing: border-box;
  padding: 12px;
  border: 1px solid var(--eden-layout-border);
  border-radius: var(--eden-radius-lg, 18px);
  color: var(--eden-frame-fg);
  background: var(--eden-layout-bg);
  box-shadow: var(--eden-layout-shadow);
  backdrop-filter: var(--eden-glass-strong, blur(26px) saturate(160%));
  pointer-events: auto;
  touch-action: auto;
  user-select: none;
  font: 12px var(--eden-font-family-base, sans-serif);
}

#eden-app-frame-overlay .eden-tile-layout-heading {
  height: 22px;
  display: grid;
  place-items: center;
  font-weight: var(--eden-font-weight-semibold, 600);
}

#eden-app-frame-overlay .eden-tile-layout-map {
  display: grid;
  grid-template: 43px 62px 43px / 55px 76px 55px;
  gap: 4px;
  width: 194px;
  margin: 4px auto;
  place-items: center;
}

#eden-app-frame-overlay .eden-tile-layout-edge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

#eden-app-frame-overlay .eden-tile-layout-edge-top {
  --eden-edge-rotation: -90deg;
  grid-area: 1 / 2;
}

#eden-app-frame-overlay .eden-tile-layout-edge-right {
  grid-area: 2 / 3;
  flex-direction: column;
}

#eden-app-frame-overlay .eden-tile-layout-edge-bottom {
  --eden-edge-rotation: 90deg;
  grid-area: 3 / 2;
}

#eden-app-frame-overlay .eden-tile-layout-edge-left {
  --eden-edge-rotation: 180deg;
  grid-area: 2 / 1;
  flex-direction: column;
}

#eden-app-frame-overlay .eden-tile-layout-edge button {
  all: revert;
  width: 27px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  padding: 0;
  border: none;
  border-radius: var(--eden-radius-xs, 6px);
  color: var(--eden-frame-muted);
  background: var(--eden-layout-action-bg);
  box-shadow: var(--eden-layout-action-shadow);
  cursor: pointer;
  transition: all var(--eden-duration-instant, 100ms) ease;
}

#eden-app-frame-overlay .eden-tile-layout-edge button:hover {
  color: white;
  background: var(--eden-color-accent-primary, #5b7cfa);
  box-shadow: 0 4px 10px rgba(63, 91, 205, 0.3);
}

#eden-app-frame-overlay .eden-tile-layout-edge button:hover {
  transform: translateY(-1px);
}

#eden-app-frame-overlay .eden-tile-layout-edge button:focus-visible {
  outline: 2px solid var(--eden-color-accent-primary, #5b7cfa);
  outline-offset: 2px;
}

#eden-app-frame-overlay .eden-tile-layout-edge button:disabled {
  opacity: 0.16;
  cursor: default;
  box-shadow: none;
  transform: none;
}

#eden-app-frame-overlay .eden-tile-layout-window {
  position: relative;
  grid-area: 2 / 2;
  width: 72px;
  height: 52px;
  color: var(--eden-color-accent-primary, #5b7cfa);
}

#eden-app-frame-overlay .eden-tile-layout-window > svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: currentColor;
}

#eden-app-frame-overlay .eden-tile-layout-edge button svg {
  width: 17px;
  height: 17px;
  transform: rotate(var(--eden-edge-rotation, 0deg));
}

#eden-app-frame-overlay .eden-tile-layout-window-body {
  fill: rgba(91, 124, 250, 0.12);
  stroke: currentColor;
  stroke-width: 1.7;
}

#eden-app-frame-overlay .eden-tile-layout-window-bar {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.2;
  opacity: 0.65;
}

@media (prefers-reduced-motion: reduce) {
  #eden-app-frame-overlay :is(.eden-app-frame-title-chevron, button, svg) {
    transition: none;
  }
}

#eden-app-frame-overlay #eden-app-frame-controls {
  all: revert;
  /* Now only set what we actually need */
  display: flex;
  gap: 8px;
  -webkit-app-region: no-drag;
  align-items: center;
  background: var(--eden-frame-glass);
  backdrop-filter: blur(20px) saturate(180%);
  padding: 4px;
  border-radius: 10px;
  height: 32px;
  box-sizing: border-box;
  box-shadow: var(--eden-frame-shadow);
}

#eden-app-frame-overlay .eden-app-frame-button {
  all: revert;
  /* Now only set what we actually need */
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  color: var(--eden-frame-muted);
  line-height: 1;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-weight: 400;
  padding: 0;
  margin: 0;
  box-sizing: border-box;
  flex-shrink: 0;
}

#eden-app-frame-overlay .eden-app-frame-button:hover {
  background: var(--eden-frame-hover);
  transform: scale(1.05);
}

#eden-app-frame-overlay .eden-app-frame-button.close:hover {
  background: #e81123;
  color: white;
  transform: scale(1.05);
}

#eden-app-frame-overlay .eden-app-frame-button:active {
  transform: scale(0.95);
}

#eden-app-frame-overlay .eden-app-frame-button.minimize {
  font-size: 20px;
  font-weight: 300;
}

#eden-app-frame-overlay .eden-app-frame-button.close {
  font-size: 20px;
  font-weight: 400;
}

/* Adjust body to account for title bar */
body.eden-framed.eden-framed {
  padding-top: 41px;
}
