:root {
  --tile-gap: 6px;
  --tile-size: clamp(72px, 22vw, 110px);
  --bg: #000;
  --text: #ffffff;
  --muted: rgba(255,255,255,0.65);

  /* Authentic Windows Phone tile palette */
  --blue:    #0078D4;
  --cyan:    #00B7C3;
  --teal:    #008272;
  --green:   #498205;
  --lime:    #7BB661;
  --yellow:  #FFB900;
  --orange:  #CA5010;
  --red:     #E81123;
  --pink:    #E3008C;
  --magenta: #B4009E;
  --purple:  #5C2D91;
  --indigo:  #4B0082;
  --gray:    #525252;
  --dark:    #1F1F1F;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', 'Segoe UI Light', 'Open Sans', system-ui, -apple-system, "Helvetica Neue", sans-serif;
  font-weight: 300;
  overflow-x: hidden;
  min-height: 100vh;
}

body { padding: 0; perspective: 1000px; }

/* ============ UPDATES BANNER ============ */
.updates-bar {
  position: relative;
  display: flex;
  align-items: center;
  background: linear-gradient(90deg, #B4009E 0%, #E81123 100%);
  color: #fff;
  height: 32px;
  overflow: hidden;
  cursor: pointer;
  font-weight: 400;
  font-size: 12.5px;
  letter-spacing: 0.2px;
  user-select: none;
  outline: none;
}
.updates-bar:hover { filter: brightness(1.08); }
.updates-bar:focus-visible { box-shadow: inset 0 0 0 2px rgba(255,255,255,0.6); }

.updates-icon {
  flex-shrink: 0;
  padding: 0 12px 0 14px;
  background: rgba(0,0,0,0.18);
  align-self: stretch;
  display: flex;
  align-items: center;
  font-size: 14px;
  z-index: 2;
  position: relative;
  /* Subtle vertical pulse */
  animation: bellPulse 2.6s ease-in-out infinite;
}
@keyframes bellPulse {
  0%, 90%, 100% { transform: scale(1); }
  92% { transform: scale(1.18) rotate(-8deg); }
  94% { transform: scale(1.18) rotate(8deg); }
  96% { transform: scale(1.18) rotate(-4deg); }
}

.updates-track {
  display: flex;
  flex: 1;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 12px, #000 calc(100% - 30px), transparent);
          mask-image: linear-gradient(90deg, transparent, #000 12px, #000 calc(100% - 30px), transparent);
}
.updates-seq {
  display: flex;
  flex-shrink: 0;
  white-space: nowrap;
  animation: marquee 38s linear infinite;
  padding-right: 32px;
}
.updates-bar:hover .updates-seq { animation-play-state: paused; }
.updates-item {
  padding: 0 28px 0 4px;
  position: relative;
}
.updates-item::after {
  content: '·';
  position: absolute;
  right: 10px;
  opacity: 0.5;
}
.updates-item:last-child::after { content: ''; }

@keyframes marquee {
  from { transform: translateX(0); }
  to   { transform: translateX(-100%); }
}

/* On the body itself, push content down */
.updates-bar + .status-bar { margin-top: 0; }
body > .status-bar:first-of-type,
.updates-bar + .status-bar { padding-top: 24px; }

/* Main app padding (since body padding is now 0) */
.status-bar, .start-header, .tiles {
  padding-left: 16px;
  padding-right: 16px;
}
.status-bar { padding-top: 24px; padding-bottom: 16px; }
.start-header { padding-top: 8px; padding-bottom: 28px; }
.tiles { padding-bottom: 80px; }
@media (min-width: 720px) {
  .status-bar, .start-header, .tiles { padding-left: 20px; padding-right: 20px; }
  .status-bar { padding-top: 40px; }
}

/* Status bar */
.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 400;
  color: rgba(255,255,255,0.85);
  padding: 0 4px 16px;
  letter-spacing: 0.5px;
  gap: 8px;
}
.status-bar .date {
  flex: 1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  opacity: 0.85;
}
.status-bar .weather {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}
.status-bar .weather .w-icon { font-size: 13px; }
.status-bar .weather .w-temp { font-weight: 400; }
.status-bar .weather .w-city { opacity: 0.85; }

/* Header "Start" */
.start-header {
  font-size: 42px;
  font-weight: 200;
  letter-spacing: -1px;
  padding: 8px 6px 28px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}
.start-header .more {
  font-size: 22px;
  font-weight: 300;
  opacity: 0.5;
  cursor: pointer;
  padding-bottom: 6px;
  transition: opacity 0.2s;
}
.start-header .more:hover { opacity: 1; }

/* Tile grid */
.tiles {
  display: grid;
  grid-template-columns: repeat(4, var(--tile-size));
  gap: var(--tile-gap);
  justify-content: center;
  max-width: 100%;
}

@media (min-width: 720px) {
  :root { --tile-size: 120px; }
  .tiles { grid-template-columns: repeat(6, var(--tile-size)); }
  body { padding: 40px 20px 80px; }
  .start-header { padding-bottom: 36px; }
}

@media (min-width: 1100px) {
  .tiles { grid-template-columns: repeat(8, var(--tile-size)); }
}

/* Tile base */
.tile {
  width: var(--tile-size);
  height: var(--tile-size);
  background: var(--blue);
  color: #fff;
  position: relative;
  cursor: pointer;
  overflow: hidden;
  border: none;
  outline: none;
  text-align: left;
  transition: transform 0.15s cubic-bezier(0.2, 0, 0, 1);
  transform-style: preserve-3d;
  will-change: transform;
  opacity: 0;
  animation: tileIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes tileIn {
  from { opacity: 0; transform: translateY(20px) rotateX(40deg); }
  to   { opacity: 1; transform: translateY(0) rotateX(0); }
}

.tile:nth-child(1)  { animation-delay: 0.00s; }
.tile:nth-child(2)  { animation-delay: 0.04s; }
.tile:nth-child(3)  { animation-delay: 0.08s; }
.tile:nth-child(4)  { animation-delay: 0.12s; }
.tile:nth-child(5)  { animation-delay: 0.16s; }
.tile:nth-child(6)  { animation-delay: 0.20s; }
.tile:nth-child(7)  { animation-delay: 0.24s; }
.tile:nth-child(8)  { animation-delay: 0.28s; }
.tile:nth-child(9)  { animation-delay: 0.32s; }
.tile:nth-child(10) { animation-delay: 0.36s; }
.tile:nth-child(11) { animation-delay: 0.40s; }
.tile:nth-child(12) { animation-delay: 0.44s; }
.tile:nth-child(13) { animation-delay: 0.48s; }
.tile:nth-child(14) { animation-delay: 0.52s; }
.tile:nth-child(15) { animation-delay: 0.56s; }
.tile:nth-child(16) { animation-delay: 0.60s; }
.tile:nth-child(n+17) { animation-delay: 0.64s; }

/* Tile sizes */
.tile.size-small  { /* default */ }
.tile.size-medium { width: calc(var(--tile-size) * 2 + var(--tile-gap));     height: calc(var(--tile-size) * 2 + var(--tile-gap));     grid-column: span 2; grid-row: span 2; }
.tile.size-wide   { width: calc(var(--tile-size) * 4 + var(--tile-gap) * 3); height: calc(var(--tile-size) * 2 + var(--tile-gap));     grid-column: span 4; grid-row: span 2; }

/* Tile inner content */
.tile-inner {
  width: 100%;
  height: 100%;
  padding: 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
}
.tile.size-medium .tile-inner,
.tile.size-wide .tile-inner { padding: 14px; }

.tile-icon { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; }
.tile.size-medium .tile-icon,
.tile.size-wide .tile-icon { width: 44px; height: 44px; }
.tile-icon svg { width: 100%; height: 100%; fill: #fff; }

.tile-label { font-size: 13px; font-weight: 400; letter-spacing: 0.2px; line-height: 1.2; }
.tile.size-medium .tile-label,
.tile.size-wide .tile-label { font-size: 15px; }

/* Tile color classes */
.bg-blue    { background: var(--blue); }
.bg-cyan    { background: var(--cyan); }
.bg-teal    { background: var(--teal); }
.bg-green   { background: var(--green); }
.bg-lime    { background: var(--lime); }
.bg-yellow  { background: var(--yellow); color: #1a1a1a; }
.bg-yellow .tile-icon svg { fill: #1a1a1a; }
.bg-orange  { background: var(--orange); }
.bg-red     { background: var(--red); }
.bg-pink    { background: var(--pink); }
.bg-magenta { background: var(--magenta); }
.bg-purple  { background: var(--purple); }
.bg-indigo  { background: var(--indigo); }
.bg-gray    { background: var(--gray); }
.bg-dark    { background: var(--dark); }

/* Hover (desktop) */
@media (hover: hover) {
  .tile:hover { outline: 2px solid rgba(255,255,255,0.6); outline-offset: -2px; }
}

/* Live tile content - Calendar shows date */
.live-calendar { display: flex; flex-direction: column; justify-content: space-between; height: 100%; padding: 14px; }
.live-calendar .day-name { font-size: 14px; font-weight: 400; }
.live-calendar .day-num  { font-size: 64px; font-weight: 200; line-height: 1; margin-top: -8px; }
.live-calendar .month    { font-size: 12px; opacity: 0.85; margin-top: 4px; letter-spacing: 1px; text-transform: uppercase; }

/* Live tile - Weather */
.live-weather { padding: 14px; height: 100%; display: flex; flex-direction: column; justify-content: space-between; }
.live-weather .city { font-size: 13px; font-weight: 400; opacity: 0.9; }
.live-weather .temp { font-size: 56px; font-weight: 200; line-height: 1; }
.live-weather .cond { font-size: 13px; opacity: 0.9; }
.live-weather .row  { display: flex; justify-content: space-between; align-items: flex-end; }

/* Live tile - Photos: rotating images */
.live-photos { width: 100%; height: 100%; position: relative; overflow: hidden; }
.live-photos .slide { position: absolute; inset: 0; background-size: cover; background-position: center; opacity: 0; animation: photoRotate 16s infinite; }
.live-photos .slide:nth-child(1) { animation-delay: 0s;  }
.live-photos .slide:nth-child(2) { animation-delay: 4s;  }
.live-photos .slide:nth-child(3) { animation-delay: 8s;  }
.live-photos .slide:nth-child(4) { animation-delay: 12s; }

@keyframes photoRotate {
  0%   { opacity: 0; transform: scale(1.05); }
  5%   { opacity: 1; transform: scale(1); }
  25%  { opacity: 1; transform: scale(1); }
  30%  { opacity: 0; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.05); }
}

.live-photos .photo-label {
  position: absolute; bottom: 14px; left: 14px; right: 14px;
  font-size: 15px; font-weight: 400; z-index: 2;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}

/* ============ FULL-PAGE POPUP ============ */
.sheet {
  position: fixed;
  inset: 0;
  background: #1B1B1B;
  color: #fff;
  transform: translateX(100%);
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 200;
  display: flex;
  flex-direction: column;
  visibility: hidden;
  overflow: hidden;
}
.sheet.active { transform: translateX(0); visibility: visible; }

.sheet::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: var(--blue); z-index: 1;
}

.sheet-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 32px 24px 20px; flex-shrink: 0;
}
@media (min-width: 720px) { .sheet-header { padding: 48px 56px 24px; } }

.sheet-title-wrap { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.sheet-eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: 2.5px; opacity: 0.55; font-weight: 400; }
.sheet-title { font-size: 38px; font-weight: 200; letter-spacing: -0.8px; line-height: 1.05; }
@media (min-width: 720px) { .sheet-title { font-size: 56px; } }

.sheet-close {
  background: transparent; border: 2px solid rgba(255,255,255,0.4); color: #fff;
  width: 44px; height: 44px; cursor: pointer; display: flex;
  align-items: center; justify-content: center; transition: all 0.2s; flex-shrink: 0;
}
.sheet-close:hover { background: rgba(255,255,255,0.1); border-color: #fff; }
.sheet-close svg { width: 18px; height: 18px; fill: #fff; }

.sheet-body {
  padding: 8px 24px 48px;
  overflow-y: auto; flex: 1;
  font-size: 16px; line-height: 1.65; font-weight: 300;
}
@media (min-width: 720px) {
  .sheet-body {
    padding: 16px 56px 64px;
    max-width: 720px; width: 100%; align-self: center;
    font-size: 17px;
  }
}

.sheet-body p { margin-bottom: 14px; opacity: 0.9; }
.sheet-body h3 { font-size: 20px; font-weight: 400; margin: 24px 0 12px; letter-spacing: -0.2px; }
.sheet-body ul { list-style: none; padding: 0; }
.sheet-body ul li {
  padding: 12px 0; border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex; justify-content: space-between; opacity: 0.9;
}
.sheet-body ul li:last-child { border-bottom: none; }
.sheet-body ul li span:last-child { opacity: 0.6; }
.sheet-body ul li a { color: var(--blue); text-decoration: none; }
.sheet-body ul li a:hover { text-decoration: underline; }

/* Gallery */
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 12px 0; }
.gallery .ph { aspect-ratio: 1; background-size: cover; background-position: center; }
@media (min-width: 720px) { .gallery { grid-template-columns: repeat(4, 1fr); } }

.sheet-body::-webkit-scrollbar { width: 4px; }
.sheet-body::-webkit-scrollbar-track { background: transparent; }
.sheet-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); }

/* "View details" button inside popup body — opens iframe overlay */
.details-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 20px;
  padding: 14px 22px;
  background: var(--blue);
  color: #fff;
  border: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.3px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  transition: filter 0.15s, transform 0.15s;
}
.details-btn:hover { filter: brightness(1.15); }
.details-btn:active { transform: scale(0.98); }
.details-btn svg { width: 14px; height: 14px; fill: #fff; }

/* ============ IFRAME EMBED OVERLAY ============ */
.embed-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 300;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.28s ease, visibility 0s linear 0.28s;
  display: flex;
  flex-direction: column;
}
.embed-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.28s ease, visibility 0s linear 0s;
}
.embed-overlay iframe {
  flex: 1;
  width: 100%;
  border: none;
  background: #fff;
  display: block;
}
.embed-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  width: 44px;
  height: 44px;
  background: rgba(0,0,0,0.7);
  color: #fff;
  border: 2px solid rgba(255,255,255,0.3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.embed-close:hover {
  background: rgba(0,0,0,0.9);
  border-color: rgba(255,255,255,0.8);
}
.embed-close svg { width: 18px; height: 18px; fill: #fff; }
