/* ==========================================================================
   start.css - Start screen chrome: background, header, scroller,
               semantic zoom, and the bottom app bar
   ========================================================================== */

#startscreen {
  --edge: clamp(40px, 6.5vw, 118px);
  z-index: 10;
  background: var(--start-bg-deep);
}

/* Entering Start from an app: the whole surface zooms up from slightly small,
   which is the counterpart to the tile's launch zoom. */
#startscreen.is-zooming-in { animation: start-zoom-in 300ms var(--ease-out) both; }
@keyframes start-zoom-in {
  from { opacity: 0; transform: scale(0.88); }
  to   { opacity: 1; transform: scale(1); }
}

/* --------------------------------------------------------------------------
   BACKGROUND
   A deep accent-derived wash plus one of the decorative Start patterns.
   -------------------------------------------------------------------------- */
.start-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 120% 90% at 12% 0%, rgba(255, 255, 255, 0.09), transparent 62%),
    radial-gradient(ellipse 90% 80% at 100% 100%, rgba(0, 0, 0, 0.3), transparent 60%),
    linear-gradient(148deg, var(--start-bg) 0%, var(--start-bg-deep) 100%);
}

/* Windows 8.1 added the option to let Start adopt the desktop wallpaper, which
   made switching between the two feel like one place instead of two. */
body.start-uses-desktop-bg .start-bg {
  background:
    radial-gradient(ellipse 80% 70% at 26% 22%, rgba(255, 255, 255, 0.1), transparent 60%),
    radial-gradient(ellipse 70% 60% at 82% 84%, rgba(0, 0, 0, 0.34), transparent 62%),
    linear-gradient(155deg, #17627e 0%, #0e3d54 46%, #08222f 100%);
}
body.start-uses-desktop-bg .start-bg::after { opacity: 0.18; }

/* Subtle repeating motif, echoing the Windows 8 Start backgrounds. */
.start-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='0.05' stroke-width='1'%3E%3Cpath d='M0 40h160M0 120h160M40 0v160M120 0v160'/%3E%3C/g%3E%3Cg fill='%23ffffff' fill-opacity='0.035'%3E%3Ccircle cx='40' cy='40' r='3'/%3E%3Ccircle cx='120' cy='120' r='3'/%3E%3Crect x='114' y='34' width='12' height='12'/%3E%3Crect x='34' y='114' width='12' height='12'/%3E%3C/g%3E%3C/svg%3E");
}

/* --------------------------------------------------------------------------
   HEADER
   -------------------------------------------------------------------------- */
.start-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 132px;
  padding: 54px var(--edge) 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  z-index: 3;
  pointer-events: none;
}

.start-title {
  font-family: var(--font-light);
  font-weight: 200;
  font-size: 42px;
  line-height: 1;
  letter-spacing: -0.005em;
  animation: header-enter 380ms var(--ease-out) both;
}

.start-user {
  display: flex;
  align-items: center;
  gap: 11px;
  pointer-events: auto;
  padding: 4px;
  animation: header-enter 380ms 60ms var(--ease-out) both;
}
.start-user:hover .start-user-pic { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.85); }

.start-user-name {
  font-size: 15px;
  font-weight: 400;
  color: #fff;
}

.start-user-pic {
  width: 38px;
  height: 38px;
  font-size: 15px;
  font-weight: 400;
  font-family: var(--font);
  background: rgba(255, 255, 255, 0.28);
  transition: box-shadow var(--dur-fast) var(--ease-std);
}

/* --------------------------------------------------------------------------
   SCROLLER
   Start scrolls horizontally; the grid is a row of groups.
   -------------------------------------------------------------------------- */
.start-scroller {
  position: absolute;
  top: 132px;
  left: 0;
  right: 0;
  bottom: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0 var(--edge);
  z-index: 2;
  scroll-behavior: smooth;
}

.start-grid {
  display: flex;
  align-items: flex-start;
  gap: var(--group-gap);
  min-height: 100%;
  padding-bottom: 34px;
  width: max-content;
}

/* Row count adapts to viewport height so tiles never clip - Windows 8 did the
   same, fitting 3 medium rows on 768px displays and more on taller ones. */
.tile-group-tiles { --rows: 6; }
@media (min-height: 900px)  { .tile-group-tiles { --rows: 8; } }
@media (min-height: 1160px) { .tile-group-tiles { --rows: 10; } }
@media (max-height: 660px)  { .tile-group-tiles { --rows: 4; } }

/* --------------------------------------------------------------------------
   SEMANTIC ZOOM
   Ctrl+scroll, the corner button, or pinch collapses Start into labelled
   group blocks that you click to jump back into.
   -------------------------------------------------------------------------- */
/* Zooming out shrinks and fades the real grid away, so the group blocks read
   as the same content pulled back rather than a panel laid on top of it. */
.start-scroller {
  transition: transform var(--dur-med) var(--ease-out),
              opacity var(--dur-med) var(--ease-out);
  transform-origin: 12% 42%;
}
.start-scroller.is-zoomed-out {
  transform: scale(0.42);
  opacity: 0;
  pointer-events: none;
}

.semantic-zoom {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.22);
  animation: sz-in 240ms var(--ease-out) both;
}
/* Blocks start oversized and settle, matching the direction of the zoom. */
@keyframes sz-in {
  from { opacity: 0; transform: scale(1.42); }
  to   { opacity: 1; transform: scale(1); }
}
.semantic-zoom.is-leaving { animation: sz-out 200ms var(--ease-in) both; }
@keyframes sz-out {
  to { opacity: 0; transform: scale(1.42); }
}

.semantic-groups {
  display: flex;
  align-items: center;
  gap: 26px;
  padding: 0 var(--edge);
  max-width: 100%;
  overflow-x: auto;
}

.semantic-group {
  flex: none;
  width: 232px;
  height: 176px;
  padding: 13px 15px;
  background: rgba(255, 255, 255, 0.14);
  display: flex;
  flex-direction: column;
  gap: 11px;
  transition: background-color var(--dur-fast) var(--ease-std),
              transform var(--dur-fast) var(--ease-out);
}
.semantic-group:hover { background: rgba(255, 255, 255, 0.24); }
.semantic-group:active { transform: scale(0.96); }

.semantic-group-name {
  font-family: var(--font-semilight);
  font-weight: 300;
  font-size: 17px;
  color: #fff;
}

/* Miniature of the group's tiles - same colours, same relative proportions. */
.semantic-mini {
  display: grid;
  grid-template-rows: repeat(6, 12px);
  grid-auto-columns: 12px;
  grid-auto-flow: column dense;
  gap: 2px;
  align-content: start;
}
.semantic-mini i { display: block; background: var(--tile-color, var(--accent)); }
.semantic-mini i.m-sm { grid-row: span 1; grid-column: span 1; }
.semantic-mini i.m-md { grid-row: span 2; grid-column: span 2; }
.semantic-mini i.m-wd { grid-row: span 2; grid-column: span 4; }
.semantic-mini i.m-lg { grid-row: span 4; grid-column: span 4; }

/* Zoom-out affordance, bottom-right. */
.zoom-out-button {
  position: absolute;
  right: 20px;
  bottom: 20px;
  width: 30px;
  height: 30px;
  z-index: 5;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.28);
  color: #fff;
  opacity: 0;
  transition: opacity var(--dur-med) var(--ease-std),
              background-color var(--dur-fast) var(--ease-std);
}
.zoom-out-button::before {
  content: '';
  width: 13px;
  height: 2px;
  background: currentColor;
}
#startscreen:hover .zoom-out-button { opacity: 1; }
.zoom-out-button:hover { background: rgba(255, 255, 255, 0.45); }

/* --------------------------------------------------------------------------
   APP BAR
   Right-clicking a tile slides this up from the bottom edge.
   -------------------------------------------------------------------------- */
.appbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 120;
  min-height: 88px;
  padding: 0 26px;
  background: var(--appbar-bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  animation: appbar-in 200ms var(--ease-out) both;
}
@keyframes appbar-in {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
.appbar.is-leaving { animation: appbar-out 180ms var(--ease-in) both; }
@keyframes appbar-out {
  to { transform: translateY(100%); }
}

.appbar-left,
.appbar-right { display: flex; align-items: center; gap: 26px; }

.appbar-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 68px;
  padding: 6px 4px;
  color: #fff;
}
.appbar-button:disabled { opacity: 0.35; pointer-events: none; }

.appbar-button-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.82);
  border-radius: 50%;
  transition: background-color var(--dur-fast) var(--ease-std),
              color var(--dur-fast) var(--ease-std);
}
.appbar-button-icon svg { width: 19px; height: 19px; }
.appbar-button:hover .appbar-button-icon { background: rgba(255, 255, 255, 0.18); }
.appbar-button:active .appbar-button-icon { background: #fff; color: var(--appbar-bg); }

.appbar-button-label { font-size: 12px; font-weight: 400; }

/* Resize flyout that opens above the app bar's Resize button. */
.size-menu {
  position: fixed;
  z-index: 130;
  min-width: 138px;
  padding: 4px 0;
  background: #2b2b2b;
  box-shadow: 0 3px 18px rgba(0, 0, 0, 0.55);
  animation: size-menu-in 140ms var(--ease-out) both;
}
@keyframes size-menu-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

.size-menu-item {
  display: block;
  width: 100%;
  padding: 9px 18px;
  text-align: left;
  font-size: 14px;
  color: #fff;
  transition: background-color var(--dur-fast) var(--ease-std);
}
.size-menu-item:hover { background: var(--accent); }
.size-menu-item.is-active { font-weight: 600; }
.size-menu-item.is-active::after { content: ' ✓'; opacity: 0.75; }

/* --------------------------------------------------------------------------
   HOT CORNERS
   Invisible 6×6 targets, matching where Windows 8 put them.
   -------------------------------------------------------------------------- */
.hot-corner {
  position: fixed;
  width: 6px;
  height: 6px;
  z-index: 300;
}
#hc-tr { top: 0; right: 0; }
#hc-br { bottom: 0; right: 0; }
#hc-tl { top: 0; left: 0; }
#hc-bl { bottom: 0; left: 0; }

/* Top-left corner thumbnail of the previously used app. */
.corner-preview {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 260;
  width: 148px;
  height: 96px;
  background: #1f1f1f;
  box-shadow: 0 3px 18px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: #fff;
  animation: corner-in 160ms var(--ease-out) both;
  cursor: pointer;
}
@keyframes corner-in {
  from { opacity: 0; transform: translate(-14px, -14px) scale(0.9); }
  to   { opacity: 1; transform: none; }
}
.corner-preview svg { width: 26px; height: 26px; }
.corner-preview span { font-size: 12px; }

/* Left-edge switcher strip listing everything currently open. */
.switcher {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 255;
  width: 92px;
  padding: 8px;
  background: rgba(24, 24, 24, 0.96);
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: switcher-in 200ms var(--ease-out) both;
}
@keyframes switcher-in {
  from { transform: translateX(-100%); }
  to   { transform: translateX(0); }
}

.switcher-item {
  width: 76px;
  height: 52px;
  background: var(--tile-color, #333);
  display: grid;
  place-items: center;
  color: #fff;
  transition: transform var(--dur-fast) var(--ease-out);
}
.switcher-item:hover { transform: scale(1.05); }
.switcher-item svg { width: 22px; height: 22px; }

/* --------------------------------------------------------------------------
   ACCOUNT FLYOUT
   Hangs off the name in the Start header. Flat and square like every other
   Modern flyout - the shadow is the only thing lifting it off the tiles.
   -------------------------------------------------------------------------- */

.user-menu {
  position: fixed;
  z-index: 700;
  min-width: 208px;
  padding: 3px;
  background: #1b1b1b;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.5);
  animation: user-menu-in 150ms var(--ease-out);
  transform-origin: top right;
}

@keyframes user-menu-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: none; }
}

.user-menu-item {
  display: block;
  width: 100%;
  padding: 9px 14px;
  border: 0;
  background: none;
  color: rgba(255, 255, 255, 0.88);
  font-family: var(--font);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.user-menu-item:hover,
.user-menu-item:focus-visible {
  outline: none;
  background: var(--accent);
  color: #fff;
}

.user-menu-sep {
  height: 1px;
  margin: 4px 0;
  background: rgba(255, 255, 255, 0.14);
}

@media (prefers-reduced-motion: reduce) {
  .user-menu { animation: none; }
}
