/* Beauty camera - layout is fixed to the viewport: view on top, controls at the bottom. */

:root {
  --ground: #141018;
  --panel: #1e1824;
  --edge: #342b3d;
  --text: #f3eef7;
  --dim: #a99cb4;
  --accent: #f2679f;
  --accent-ink: #ffffff;
  --danger: #ffb4b4;

  /* Height of one comfortable touch target. */
  --touch: 48px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--ground);
  color: var(--text);
  font-family: "Hiragino Sans", "Yu Gothic UI", "Noto Sans JP", system-ui, sans-serif;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
  /* The floating control bar hangs off this box, so it stops at the safe area
   * instead of under the home bar. */
  position: relative;
  /* Keep clear of the notch and the home bar. */
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ---------- live view ---------- */

/* The picture gets the whole screen and sits at the top of it; the controls
 * float over the empty part below. Giving the controls a row of their own ate
 * a third of the screen and pushed the face into what was left. */
.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background: #000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow: hidden;
}

#source {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* The canvas is already cut to the shape of this box, so it fills it exactly.
 * contain is the safety net for the moment after a turn of the phone, before
 * the next frame is drawn at the new shape. */
#view {
  width: 100%;
  height: 100%;
  object-fit: contain;
  /* Any space left over belongs at the bottom, under the controls, not as a
   * black band above the face. */
  object-position: 50% 0;
  display: block;
}

/* ---------- overlays ---------- */

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 28px;
  text-align: center;
  background: rgba(20, 16, 24, .94);
}

.overlay[hidden] { display: none; }

.overlay-title {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  line-height: 1.5;
}

.overlay-note {
  margin: 0;
  font-size: 15px;
  line-height: 1.85;
  color: var(--dim);
  max-width: 34em;
}

.overlay-blocked .overlay-title { color: var(--danger); }

.overlay-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 4px;
}

/* Here the label decides the width. Sharing the row equally, as the buttons
 * under a photo do, split "もう一度ためす" across two lines. */
.overlay-actions .wide {
  flex: 0 1 auto;
  white-space: nowrap;
}

/* ---------- the photo that was just taken ---------- */

.result {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: #000;
}

.result[hidden] { display: none; }

#shot {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: 50% 0;
  display: block;
}

/* ---------- control bars ---------- */

.bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  /* Dark enough to read against a bright picture, clear enough to see through
   * where the picture reaches. */
  background: linear-gradient(180deg,
    rgba(20, 16, 24, 0) 0%,
    rgba(20, 16, 24, .72) 22%,
    rgba(20, 16, 24, .93) 100%);
}

/* On a short screen the controls would reach up into the face, so they get
 * tighter: shorter rows, a smaller shutter, no status line. */
@media (max-height: 780px) {
  .dial { min-height: 40px; }
  input[type="range"] { height: 40px; }
  .dials { gap: 2px; }
  .shutter { width: 64px; height: 64px; }
  .shutter span { width: 48px; height: 48px; }
  .round { width: 46px; height: 46px; }
  #live-bar .face-state { display: none; }
}

.bar[hidden] { display: none; }

/* ---------- dials ---------- */

.dials {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dials[hidden] { display: none; }

/* The handle that folds the sliders away. Small, and out of the way of the
 * shutter, but still a full touch target. */
.handle {
  align-self: center;
  min-height: 36px;
  padding: 6px 18px;
  border-radius: 999px;
  border: 1px solid var(--edge);
  background: rgba(42, 34, 51, .82);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.handle[aria-expanded="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.dial {
  display: grid;
  grid-template-columns: 4.2em 1fr 2.4em;
  align-items: center;
  gap: 12px;
  /* The whole row is the target, so the thin slider is easy to grab. */
  min-height: var(--touch);
  cursor: pointer;
}

.dial-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .02em;
}

.dial-value {
  font-size: 14px;
  color: var(--dim);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: var(--touch);
  margin: 0;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: var(--edge);
}
input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: var(--edge);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--panel);
  margin-top: -10px;
}
input[type="range"]::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border: 3px solid var(--panel);
  border-radius: 50%;
  background: var(--accent);
}

input[type="range"]:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
  border-radius: 6px;
}

/* ---------- shutter row ---------- */

.shutter-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  justify-items: center;
}

.round {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid var(--edge);
  background: #2a2233;
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}

.round svg { width: 24px; height: 24px; }

.round[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.shutter {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 4px solid var(--text);
  background: transparent;
  padding: 0;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.shutter span {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--text);
  display: block;
  transition: transform .12s ease;
}

.shutter:active span { transform: scale(.86); }

.shutter:disabled { opacity: .4; cursor: default; }

.round:focus-visible,
.shutter:focus-visible,
button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

/* ---------- buttons ---------- */

.wide {
  flex: 1 1 0;
  min-height: var(--touch);
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  padding: 12px 16px;
}

.solid {
  background: var(--accent);
  color: var(--accent-ink);
  border: 1px solid var(--accent);
}

.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--edge);
}

.result-actions {
  display: flex;
  gap: 12px;
}

/* ---------- status line ---------- */

.face-state {
  margin: 0;
  font-size: 13px;
  line-height: 1.7;
  color: var(--dim);
  text-align: center;
  min-height: 1.7em;
}

@media (prefers-reduced-motion: reduce) {
  .shutter span { transition: none; }
}
