/* The break-glass dialog: a dark pill on a black page, and over it a pane of smoked glass with a fire-alarm red.
   The pane, its cracks and its pieces are moved by script.js. */
:root {
  --page: #000000;          /* the page */
  --pill: #131417;          /* the Emergency access button */
  --pill-hover: #1b1c20;    /* the button under the pointer */
  --pill-line: #2a2c31;     /* the button's edge */
  --ink: #f3f2ee;           /* the words */
  --muted: #a2a4a9;         /* the explanation */
  --faint: #74777d;         /* the time it ends */
  --glass-top: #1a1c20;     /* the glass, at the top */
  --glass-bottom: #0f1012;  /* the glass, at the bottom */
  --glass-edge: rgba(255, 255, 255, 0.11);    /* the polished edge of the glass */
  --alarm: #e5392e;         /* Break glass, the hammer */
  --alarm-hover: #f04a3e;   /* Break glass under the pointer */
  --alarm-soft: rgba(229, 57, 46, 0.15);      /* behind the shield */
  --quiet: rgba(255, 255, 255, 0.08);         /* Cancel and End */
  --quiet-hover: rgba(255, 255, 255, 0.13);
  --on: #170b0a;            /* the button while the emergency access is on */
  --on-line: rgba(229, 57, 46, 0.45);         /* its edge */
}

* {
  box-sizing: border-box;
}

/* a tap is a click at once: no wait for a double tap, no zoom */
html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Reddit Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.stage {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* the hammer is raised from the end of its handle */
.hammer {
  transform-origin: 19% 81%;
}

/* where its point is: the glass breaks there */
.hammer__tip {
  stroke: none;
}

/* ---------------------------------------------------------------- the button, and the access once it is on */
/* one pill under both: its width follows what is in it, and its colours turn red while the access is on */
.slot {
  position: relative;
  display: grid;
  place-items: center;
  height: 56px;
  isolation: isolate;
}

.slot > .trigger,
.slot > .active {
  grid-area: 1 / 1;
}

.slot__pill {
  position: absolute;
  inset: 0;
  z-index: -1;
  border: 1px solid var(--pill-line);
  border-radius: 999px;
  background: var(--pill);
  transition: background-color 0.3s ease, border-color 0.45s ease, transform 0.25s cubic-bezier(0.3, 1.5, 0.5, 1);
}

.slot.is-on .slot__pill {
  border-color: var(--on-line);
  background: var(--on);
}

.trigger {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  height: 56px;
  padding: 0 27px 0 23px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font: 620 16px/1 'Reddit Sans Variable', system-ui, sans-serif;
  letter-spacing: -0.005em;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.trigger .hammer {
  width: 21px;
  height: 21px;
  color: var(--alarm);
  stroke-width: 2;
  transition: transform 0.35s cubic-bezier(0.3, 1.6, 0.5, 1);
}

.trigger:active ~ .slot__pill {
  transform: scale(0.97);
}

@media (hover: hover) {
  .trigger:hover ~ .slot__pill {
    background: var(--pill-hover);
  }

  /* under the pointer the hammer is raised, ready */
  .trigger:hover .hammer {
    transform: rotate(-24deg);
  }
}

.trigger:active .hammer {
  transform: rotate(10deg);
  transition-duration: 0.08s;
}

.trigger:focus-visible {
  outline: none;
}

.trigger:focus-visible ~ .slot__pill {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

.active {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 56px;
  padding: 0 8px 0 21px;
  white-space: nowrap;
}

.active[hidden],
.trigger[hidden] {
  display: none;
}

.active__icon {
  width: 21px;
  height: 21px;
  color: var(--alarm);
  stroke-width: 2;
}

.active__name {
  font-size: 16px;
  font-weight: 620;
}

.active__clock {
  min-width: 46px;
  margin-right: 4px;
  color: #ff8a80;
  font-size: 16px;
  font-weight: 560;
  font-variant-numeric: tabular-nums;
}

.active__end {
  height: 40px;
  padding: 0 17px;
  border: 0;
  border-radius: 999px;
  background: var(--quiet);
  color: var(--ink);
  font: 620 15px/1 'Reddit Sans Variable', system-ui, sans-serif;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.2s cubic-bezier(0.3, 1.6, 0.5, 1);
  -webkit-tap-highlight-color: transparent;
}

.active__end:active {
  transform: scale(0.95);
}

/* ---------------------------------------------------------------- the dialog's own buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 46px;
  padding: 0 19px;
  border: 0;
  border-radius: 13px;
  font: 620 15px/1 'Reddit Sans Variable', system-ui, sans-serif;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.2s cubic-bezier(0.3, 1.6, 0.5, 1);
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.96);
}

.btn--quiet {
  background: var(--quiet);
  color: var(--ink);
}

.btn--break {
  padding-left: 16px;
  background: var(--alarm);
  color: #ffffff;
}

.btn--break .hammer {
  width: 18px;
  height: 18px;
  stroke-width: 2.1;
  transition: transform 0.35s cubic-bezier(0.3, 1.6, 0.5, 1);
}

@media (hover: hover) {
  .btn--quiet:hover,
  .active__end:hover {
    background: var(--quiet-hover);
  }

  .btn--break:hover {
    background: var(--alarm-hover);
  }

  .btn--break:hover .hammer {
    transform: rotate(-24deg);
  }
}

.btn:focus-visible,
.active__end:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

/* the focus goes back by script after a click too: its ring shows only to who uses the keys */
html[data-using='pointer'] .btn:focus-visible,
html[data-using='pointer'] .active__end:focus-visible,
html[data-using='pointer'] .trigger:focus-visible ~ .slot__pill {
  outline: none;
}

/* ---------------------------------------------------------------- the layer over the page */
.layer {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: hidden;
}

.layer[hidden] {
  display: none;
}

.layer__scrim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0);
}

/* the pane: moved by the script on springs (rise, tilt, the blow of the hammer) */
.pane {
  position: relative;
  width: min(420px, 100%);
  outline: none;
  will-change: transform;
}

/* ---------------------------------------------------------------- the glass */
.glass {
  position: relative;
  padding: 24px 24px 22px;
  overflow: hidden;
  border-radius: 24px;
  /* two thin streaks of reflected light that stay on the glass, the upper corner a touch lighter */
  background:
    linear-gradient(112deg, rgba(255, 255, 255, 0) 63%, rgba(255, 255, 255, 0.045) 66%, rgba(255, 255, 255, 0) 70%, rgba(255, 255, 255, 0) 72%, rgba(255, 255, 255, 0.03) 73.5%, rgba(255, 255, 255, 0) 76%),
    linear-gradient(158deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0) 40%),
    linear-gradient(180deg, var(--glass-top), var(--glass-bottom));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.17),
    inset 0 0 0 1px var(--glass-edge),
    inset 0 -1px 0 rgba(160, 220, 205, 0.06);
}

/* the light that runs across the glass as it tilts: placed by the script from the pane's angle */
.glass__sheen {
  position: absolute;
  top: -60%;
  left: 0;
  width: 46%;
  height: 220%;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.05) 30%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.05) 70%, rgba(255, 255, 255, 0));
  mix-blend-mode: screen;
  pointer-events: none;
  transform: translateX(-130%) rotate(22deg);
}

.glass__icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: var(--alarm-soft);
  color: var(--alarm);
}

.glass__icon svg {
  width: 23px;
  height: 23px;
  stroke-width: 1.8;
}

.glass__title {
  margin: 18px 0 0;
  font-size: 22px;
  font-weight: 680;
  line-height: 1.2;
  letter-spacing: -0.015em;
}

.glass__text {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

.glass__meta {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 14px 0 0;
  color: var(--faint);
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}

.glass__meta svg {
  flex: none;
  width: 16px;
  height: 16px;
  stroke-width: 1.8;
}

.glass__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

/* ---------------------------------------------------------------- the pieces and the cracks */
/* every piece is a copy of the glass cut by its polygon, turned in depth round its own middle */
.pane__shards {
  position: absolute;
  inset: 0;
  perspective: 900px;
  pointer-events: none;
}

.shard {
  position: absolute;
  inset: 0;
  will-change: transform;
}

.shard > .glass {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
}

.shard__shine {
  position: absolute;
  background: linear-gradient(125deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.4) 45%, rgba(255, 255, 255, 0.08));
  opacity: 0;
}

.shard__edge {
  position: absolute;
  top: 0;
  left: 0;
  overflow: visible;
  stroke: rgba(255, 255, 255, 0.34);
  stroke-width: 2;
  opacity: 0;
  clip-path: inset(0 round 24px);
}

.pane__cracks {
  position: absolute;
  top: 0;
  left: 0;
  overflow: visible;
  pointer-events: none;
}

.pane__cracks .dark {
  stroke: rgba(0, 0, 0, 0.7);
  stroke-width: 2.4;
}

.pane__cracks .light {
  stroke: rgba(255, 255, 255, 0.86);
  stroke-width: 1;
}

/* ---------------------------------------------------------------- less movement */
@media (prefers-reduced-motion: reduce) {
  .hammer,
  .trigger:active .hammer {
    transform: none;
    transition: none;
  }
  @media (hover: hover) {
    .trigger:hover .hammer,
    .btn--break:hover .hammer {
      transform: none;
      transition: none;
    }
  }
}

/* ---------------------------------------------------------------- the phone */
@media (max-width: 480px) {
  .glass {
    padding: 22px 20px 20px;
  }

  .glass__title {
    font-size: 21px;
  }

  .btn {
    padding: 0 17px;
  }

  .btn--break {
    padding-left: 15px;
  }
}
