/* Live cameras near a resort (webcams.js): a dialog on the Ski Map and the home page, a bottom sheet on phones */

.cams-dialog {
  width: min(720px, calc(100vw - 32px)); max-height: min(86vh, 860px);
  margin: auto; padding: 0;
  display: none; flex-direction: column;
  border: 0; border-radius: var(--radius-lg);
  background: var(--glass-solid); color: var(--text);
  -webkit-backdrop-filter: var(--blur-thick); backdrop-filter: var(--blur-thick);
  box-shadow: var(--shadow);
  font-family: var(--font);
}
.cams-dialog[open] { display: flex; }
.cams-dialog::backdrop { background: rgb(var(--navy-rgb) / .35); }

.cams-head { display: flex; align-items: center; gap: 12px; padding: 18px 18px 12px 20px; }
.cams-badge {
  display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 50%;
  background: var(--navy); color: #fff;
}
.cams-badge svg, .cams-close svg, .cams-foot a svg {
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.cams-badge svg { width: 20px; height: 20px; }
.cams-heading { flex: 1; min-width: 0; }
.cams-heading h2 { margin: 0; font-family: var(--font-display); font-size: 20px; font-weight: 700; color: var(--navy); }
.cams-heading p { margin: 2px 0 0; font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cams-close {
  display: grid; place-items: center; flex: none; width: 44px; height: 44px;
  border: 0; border-radius: 50%; background: var(--fill-2); color: var(--text); cursor: pointer;
}
.cams-close:hover { background: var(--fill-hover); }
.cams-close svg { width: 18px; height: 18px; }

/* flex-basis auto, not 0: with 0, Safari sizes the dialog as if the body were empty, so it shrank to its 120px minimum
   and only a strip of the camera showed */
.cams-body { flex: 1 1 auto; min-height: 120px; overflow-y: auto; padding: 4px 20px 8px; overscroll-behavior: contain; }
/* Columns with a fixed minimum (minmax(0, …) on phones): a long one-line camera name is cut with an ellipsis instead
   of widening its column past the dialog */
.cams-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
.cams-cam { display: block; min-width: 0; overflow: hidden; border-radius: var(--radius); background: var(--fill); color: inherit; text-decoration: none; }
.cams-cam:hover { background: var(--fill-hover); }
.cams-cam:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
.cams-shot { position: relative; display: block; }
.cams-cam img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: rgb(var(--navy-rgb) / .1); }
.cams-live {
  position: absolute; top: 8px; left: 8px; padding: 2px 8px; border-radius: 999px;
  background: #d70015; color: #fff; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
}

/* One camera: back, the ways to watch it, then the stream, image or timelapse. A double-tap on it (not on a button,
   link or player) leaves the preview for the resort's website, so no text gets selected and phones don't zoom. */
.cams-view { display: flex; flex-direction: column; gap: 12px; padding-bottom: 4px; touch-action: manipulation; }
.cams-stage, .cams-info { -webkit-user-select: none; user-select: none; }
.cams-viewbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.cams-back {
  display: inline-flex; align-items: center; gap: 4px; height: 44px; margin-left: -8px; padding: 0 10px 0 4px;
  border: 0; border-radius: 12px; background: none; color: var(--accent); font: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
}
.cams-back:hover { background: var(--fill); }
.cams-back svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.cams-modes { display: flex; padding: 2px; border-radius: 10px; background: var(--fill-2); }
.cams-modes button {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px;
  border: 0; border-radius: 8px; background: none; color: var(--text); font: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
}
.cams-modes button[aria-pressed="true"] { background: var(--glass-solid); font-weight: 600; box-shadow: 0 1px 3px rgb(0 0 0 / .12); }
.cams-dot { width: 8px; height: 8px; border-radius: 50%; background: #d70015; }
.cams-back:focus-visible, .cams-modes button:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }

.cams-stage {
  display: grid; place-items: center; overflow: hidden; width: 100%; aspect-ratio: 16 / 9;
  border-radius: var(--radius); background: #0b1622;
}
.cams-stage iframe { width: 100%; height: 100%; border: 0; }
/* Windy's terms: never larger than the image itself, so a small image sits in the middle */
.cams-stage img { display: block; max-width: 100%; max-height: 100%; }
.cams-info h3 { margin: 0; font-size: 17px; font-weight: 600; }
.cams-info p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.cams-info .cams-highest { margin-top: 8px; font-size: 14px; font-weight: 600; color: var(--text); }
.cams-info .cams-note { margin-top: 8px; font-size: 13px; }
.cams-info .cams-hint { margin-top: 4px; }
/* The image didn't load: the stage says so instead */
.cams-unavailable { margin: 0; padding: 24px; text-align: center; font-size: 15px; color: rgb(255 255 255 / .85); }
.cams-links { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.cams-links a { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; color: var(--accent); font-size: 15px; font-weight: 600; text-decoration: none; }
.cams-links a svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.cams-cap { display: block; padding: 8px 10px 10px; }
.cams-cap strong { display: block; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cams-cap small { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); }

.cams-loading, .cams-empty { margin: 24px 0; text-align: center; font-size: 15px; color: var(--muted); }
.cams-empty p { margin: 0 0 12px; }
.cams-retry {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 44px; padding: 0 18px; border: 0; border-radius: 12px;
  background: var(--fill-2); color: var(--text); font: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
}
.cams-retry:hover { background: var(--fill-hover); }
/* No footage: "Try again" and the way out (the resort's website, the camera's page or a web search) side by side */
.cams-empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.cams-go { color: var(--accent); text-decoration: none; }
.cams-go svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.cams-foot { display: flex; flex-direction: column; gap: 6px; padding: 12px 20px 18px; border-top: 1px solid var(--separator); }
.cams-foot a { color: var(--accent); font-weight: 600; text-decoration: none; }
.cams-foot > a { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; font-size: 15px; }
.cams-foot > a svg { width: 16px; height: 16px; }
.cams-foot small { font-size: 12px; color: var(--muted); }

/* Phones: a sheet from the bottom edge, at least three quarters of the screen tall
   whatever it holds (and up to 88% when it holds more), so the camera has room */
@media (max-width: 699px) {
  .cams-dialog {
    width: 100vw; max-width: 100vw; min-height: 75vh; min-height: 75dvh; max-height: 88vh;
    margin: auto 0 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .cams-head { padding: 16px 16px 10px; }
  .cams-body { padding: 4px 16px 8px; }
  .cams-foot { padding: 10px 16px 14px; }
  .cams-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
  .cams-modes { flex: 1 1 100%; }
  .cams-modes button { flex: 1; justify-content: center; padding: 0 8px; }
}
@media (max-width: 379px) { .cams-grid { grid-template-columns: minmax(0, 1fr); } }
