/**
 * Copyright (c) 2026 KDTech
 * Author: david@KDTech
 * All rights reserved.
 *
 * Tilefold website — product window
 *
 * A faithful, lightweight model of the Tilefold window used as the hero's
 * live demo: title bar with tabs, sidebar rail, a terminal of Blocks (status
 * stripe, running shimmer, success pulse), the Composer and the status bar.
 * The agent panel and command palette are styled in window-agent.css.
 * Everything inside is driven by terminal-demo.js.
 */

.app-window {
  --aw-bg: #0c0d13;
  --aw-panel: #11131b;
  --aw-line: rgb(255 255 255 / 0.07);
  position: relative;
  overflow: hidden;
  border: 1px solid rgb(255 255 255 / 0.1);
  border-radius: 18px;
  background: var(--aw-bg);
  box-shadow:
    var(--shadow-lg),
    inset 0 1px 0 rgb(255 255 255 / 0.06);
  font-size: 13px;
  text-align: start;
}

/* 24 px tile grid motif at a whisper of opacity. */
.app-window::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgb(255 255 255 / 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgb(255 255 255 / 0.025) 1px, transparent 1px);
  background-size: 24px 24px;
}

/* ---------- Title bar ---------- */

.aw-bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  height: 44px;
  padding-inline: 14px;
  border-block-end: 1px solid var(--aw-line);
  background: linear-gradient(#13151e, #0f1018);
}

.aw-lights {
  display: flex;
  gap: 8px;
}

.aw-lights i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ff5f57;
}

.aw-lights i:nth-child(2) {
  background: #febc2e;
}

.aw-lights i:nth-child(3) {
  background: #28c840;
}

.aw-tabs {
  display: flex;
  gap: 4px;
  min-width: 0;
}

.aw-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 8px;
  color: #8d93aa;
  font-size: 12px;
  white-space: nowrap;
}

.aw-tab.is-active {
  background: rgb(255 255 255 / 0.06);
  color: #eef0f8;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.05);
}

.aw-tab .tab-dot {
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--aurora);
}

.aw-bar-end {
  display: flex;
  gap: 8px;
  margin-inline-start: auto;
  color: #6e7590;
  font-family: var(--font-mono);
  font-size: 11px;
}

.kbd {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border: 1px solid rgb(255 255 255 / 0.12);
  border-block-end-width: 2px;
  border-radius: 5px;
  color: #b6bbd0;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.3;
}

/* ---------- Body ---------- */

.aw-body {
  position: relative;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 300px;
  height: clamp(380px, 46vw, 520px);
}

.aw-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding-block: 14px;
  border-inline-end: 1px solid var(--aw-line);
}

.aw-rail span {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgb(255 255 255 / 0.04);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.05);
}

.aw-rail span.is-active {
  background: rgb(124 92 255 / 0.22);
  box-shadow: inset 0 0 0 1px rgb(124 92 255 / 0.5);
}

/* ---------- Terminal + Blocks ---------- */

.aw-term {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.blocks {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: flex-end;
  /* Let older Blocks overflow off the top (clipped) instead of growing the pane. */
  min-height: 0;
  gap: 10px;
  padding: 16px;
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.55;
  mask-image: linear-gradient(transparent, #000 18%);
  -webkit-mask-image: linear-gradient(transparent, #000 18%);
}

.block {
  position: relative;
  flex-shrink: 0;
  padding: 10px 14px;
  padding-inline-start: 18px;
  border: 1px solid rgb(255 255 255 / 0.06);
  border-radius: 10px;
  background: rgb(255 255 255 / 0.025);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.04);
  animation: block-in 260ms var(--ease-out);
}

@keyframes block-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* The status stripe on the leading edge. */
.block::before {
  content: "";
  position: absolute;
  inset-block: 8px;
  inset-inline-start: 6px;
  width: 3px;
  border-radius: 3px;
  background: #3a4057;
}

.block.is-running::before {
  background: linear-gradient(180deg, var(--violet), var(--cyan), var(--amber), var(--violet));
  background-size: 100% 300%;
  animation: shimmer 1.6s linear infinite;
}

.block.is-ok::before {
  background: var(--ok);
  animation: pulse-ok 600ms var(--ease-out);
}

.block.is-err::before {
  background: var(--err);
}

@keyframes shimmer {
  to {
    background-position: 0 300%;
  }
}

@keyframes pulse-ok {
  0% {
    box-shadow: 0 0 0 0 rgb(61 220 151 / 0.9);
  }
  100% {
    box-shadow: 0 0 0 8px rgb(61 220 151 / 0);
  }
}

.block-head {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #6e7590;
  font-size: 11px;
}

.block-head .glyph {
  font-size: 10px;
}

.is-running .glyph {
  color: var(--run);
}

.is-ok .glyph {
  color: var(--ok);
}

.is-err .glyph {
  color: var(--err);
}

.block-head .time {
  margin-inline-start: auto;
  font-variant-numeric: tabular-nums;
}

.block-cmd {
  margin-block-start: 4px;
  color: #f4f5fb;
  white-space: pre;
}

.block-cmd .ps {
  color: var(--violet);
}

.block-out {
  margin: 6px 0 0;
  color: #9aa0b8;
  font: inherit;
  white-space: pre-wrap;
}

.block-out .c-ok {
  color: var(--ok);
}

.block-out .c-dim {
  color: #5d637a;
}

.block-out .c-cyan {
  color: var(--cyan);
}

.block-out .c-amber {
  color: var(--amber);
}

.block-out .c-err {
  color: var(--err);
}

/* ---------- Composer ---------- */

.aw-composer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 16px 14px;
  padding: 11px 14px;
  border: 1px solid rgb(255 255 255 / 0.09);
  border-radius: 12px;
  background: rgb(255 255 255 / 0.03);
  font-family: var(--font-mono);
  font-size: 12.5px;
  transition:
    border-color 200ms,
    box-shadow 200ms;
}

.aw-composer.is-focused {
  border-color: rgb(124 92 255 / 0.55);
  box-shadow: 0 0 0 3px rgb(124 92 255 / 0.15);
}

.aw-composer .mode {
  padding: 2px 7px;
  border-radius: 5px;
  background: rgb(255 255 255 / 0.06);
  color: #8d93aa;
  font-size: 10.5px;
}

.aw-composer .mode.is-ask {
  background: var(--aurora-soft);
  color: #e4e0ff;
}

.aw-composer .typed {
  color: #f4f5fb;
  white-space: pre;
  overflow: hidden;
}

.caret {
  display: inline-block;
  width: 7px;
  height: 15px;
  margin-inline-start: -6px;
  border-radius: 1px;
  background: var(--cyan);
  animation: blink 1.05s steps(1) infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

/* ---------- Status bar ---------- */

.aw-status {
  display: flex;
  align-items: center;
  gap: 18px;
  height: 30px;
  padding-inline: 14px;
  border-block-start: 1px solid var(--aw-line);
  color: #6e7590;
  font-family: var(--font-mono);
  font-size: 11px;
}

.aw-status .ok {
  color: var(--ok);
}

.aw-status .err {
  color: var(--err);
}

.aw-status .end {
  margin-inline-start: auto;
}

/* ---------- Responsive ---------- */

@media (max-width: 980px) {
  .aw-body {
    grid-template-columns: 44px minmax(0, 1fr);
  }
}

@media (max-width: 560px) {
  .aw-body {
    grid-template-columns: minmax(0, 1fr);
    height: 400px;
  }

  .aw-rail,
  .aw-bar-end,
  .aw-tab:not(.is-active) {
    display: none;
  }

  .blocks {
    font-size: 11px;
  }
}
