/* Aroma Loka Photobooth — paper, ink, and a receipt printer. */

@font-face {
  font-family: "Cormorant Garamond";
  src: url("fonts/cormorant-garamond.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Cormorant Garamond";
  src: url("fonts/cormorant-garamond-italic.woff2") format("woff2");
  font-weight: 300 700;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("fonts/inter.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --plum: #2a1f2d;
  --plum-deep: #221927;
  --plum-soft: #3a2c3d;
  --paper: #f6f1ea;
  --sand: #e6dac8;
  --sand-deep: #dccbb4;
  --ink: #1b1714;
  --ink-soft: #6b5f52;
  --amber: #b8863b;
  --amber-bright: #c9974a;
  --danger: #b3372e;
  --font-display: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --font-text: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100svh;
  background: var(--plum);
  color: var(--paper);
  font-family: var(--font-text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: var(--amber);
  color: var(--ink);
}

[hidden] {
  display: none !important;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
label:focus-within {
  outline: 3px solid currentColor;
  outline-offset: 3px;
}

.app {
  min-height: 100svh;
}

.view {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: max(20px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

/* The receipt is the object. */

.receipt {
  position: relative;
  width: 100%;
  max-width: 480px;
  padding: 28px 28px 30px;
  background: var(--paper);
  color: var(--ink);
  animation: receipt-in 0.55s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.receipt::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -9px;
  height: 10px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='10' viewBox='0 0 20 10'%3E%3Cpath d='M0 0h20v3l-5 7-5-7-5 7-5-7z' fill='%23F6F1EA'/%3E%3C/svg%3E");
  background-size: 20px 10px;
  background-repeat: repeat-x;
  pointer-events: none;
}

.display {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(44px, 10vw, 64px);
  font-weight: 500;
  line-height: 0.95;
  letter-spacing: -0.02em;
  text-align: center;
}

.display-small {
  font-size: clamp(34px, 6vw, 44px);
}

.lede {
  margin: 8px 0 4px;
  font-family: var(--font-display);
  font-size: clamp(22px, 2.5vw, 26px);
  font-style: italic;
  font-weight: 500;
  line-height: 1.2;
  text-align: center;
}

.sub {
  margin: 0;
  color: var(--ink-soft);
  font-size: 16px;
  line-height: 1.45;
  text-align: center;
}

.perf {
  height: 0;
  margin: 18px 0;
  border-top: 4px dotted rgba(27, 23, 20, 0.26);
}

.facts {
  margin: 0;
  display: grid;
  gap: 10px;
}

.facts > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
}

.facts dt {
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.4;
}

.facts dd {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.facts-dark dt {
  color: rgba(246, 241, 234, 0.62);
}

.facts-dark dd {
  color: var(--paper);
}

.btn {
  display: inline-flex;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  border: 0;
  border-radius: 0;
  font-family: var(--font-text);
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  text-align: center;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.btn-primary {
  width: 100%;
  background: var(--amber);
  color: var(--ink);
}

.btn-primary:hover {
  background: var(--amber-bright);
}

.btn-primary:active {
  transform: translateY(1px);
}

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

.btn-secondary:hover {
  background: var(--sand-deep);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.linklike {
  display: block;
  margin: 12px auto 0;
  padding: 8px;
  border: 0;
  background: none;
  color: var(--ink-soft);
  font-family: var(--font-text);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  text-align: center;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.linklike:hover {
  color: var(--ink);
}

.privacy {
  margin: 14px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.45;
  text-align: center;
}

/* Camera */

.receipt-camera {
  max-width: 480px;
  padding: 14px 16px 24px;
}

.camera-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.camera-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 500;
  line-height: 1.1;
  text-align: center;
}

.icon-btn {
  display: inline-grid;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.icon-btn:hover {
  background: var(--sand);
}

.icon-btn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.camera-frame {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--ink);
}

.camera-frame video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-frame video.mirrored {
  transform: scaleX(-1);
}

.camera-status {
  position: absolute;
  left: 10px;
  bottom: 10px;
  max-width: calc(100% - 20px);
  margin: 0;
  padding: 6px 8px;
  background: rgba(27, 23, 20, 0.72);
  color: var(--paper);
  font-size: 13px;
  line-height: 1.3;
}

.camera-status:empty {
  display: none;
}

.countdown {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(27, 23, 20, 0.32);
  color: var(--paper);
  font-family: var(--font-display);
  font-size: clamp(84px, 26vw, 120px);
  font-weight: 600;
  line-height: 1;
}

.countdown.pop {
  animation: count-pop 0.72s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}

.flash.on {
  animation: flash 0.28s ease-out both;
}

.thumbs {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 12px 0 4px;
}

.thumb {
  position: relative;
  width: 52px;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--sand);
}

.thumb.empty {
  background: transparent;
  border: 2px dotted rgba(27, 23, 20, 0.32);
}

.thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-actions {
  margin-top: 8px;
  text-align: center;
}

.shutter {
  display: inline-grid;
  width: 72px;
  height: 72px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--amber);
  color: var(--ink);
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease;
}

.shutter:hover {
  background: var(--amber-bright);
}

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

.shutter:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.shutter svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.shutter-label {
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.4;
}

.camera-error {
  margin-top: 12px;
  padding: 14px;
  background: var(--sand);
}

.camera-error p {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.5;
}

.error-actions {
  display: grid;
  gap: 8px;
}

.error-actions .btn {
  width: 100%;
}

.camera-error-on .camera-actions,
.camera-error-on .thumbs {
  display: none;
}

/* Result */

.view-result {
  display: block;
  padding: 28px 16px 40px;
}

.result-layout {
  display: grid;
  grid-template-columns: minmax(0, 340px) minmax(0, 1fr);
  gap: 56px;
  align-items: start;
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
}

.result-preview {
  grid-column: 1;
  grid-row: 1 / span 2;
  min-width: 0;
}

.result-info {
  grid-column: 2;
  grid-row: 1;
  position: sticky;
  top: 40px;
  padding-top: 10px;
  color: var(--paper);
}

.result-info .display {
  text-align: left;
}

#result-title:focus {
  outline: none;
}

.result-info .lede {
  margin: 8px 0 22px;
  color: var(--sand);
  font-size: 22px;
  text-align: left;
}

.result-info .facts {
  margin-bottom: 24px;
}

.result-actions {
  display: flex;
  max-width: 320px;
  flex-direction: column;
  gap: 10px;
}

.result-actions .btn-secondary {
  background: var(--plum-soft);
  color: var(--paper);
}

.result-actions .btn-secondary:hover {
  background: #46364a;
}

.result-actions .linklike {
  margin: 2px 0 0;
  padding-left: 0;
  color: var(--sand);
  text-align: left;
}

.result-actions .linklike:hover {
  color: var(--paper);
}

.result-settings {
  margin: 0 0 18px;
  padding-left: 0;
  color: var(--sand);
  text-align: left;
}

.result-settings:hover {
  color: var(--paper);
}

.print-note {
  max-width: 320px;
  margin: 16px 0 0;
  color: rgba(246, 241, 234, 0.62);
  font-size: 13px;
  line-height: 1.5;
}

.bt-status {
  max-width: 320px;
  margin: 12px 0 0;
  color: var(--sand);
  font-size: 12.5px;
  line-height: 1.5;
}

.print-dialog-mobile {
  display: none;
}

.btn-small {
  min-height: 42px;
  padding: 0 14px;
  font-size: 13px;
}

.frame-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.frame-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 5px;
  padding: 3px;
  border: 1px solid transparent;
  background: none;
  color: var(--ink-soft);
  font-family: var(--font-text);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.3;
  cursor: pointer;
}

.frame-card canvas,
.frame-card img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  background: var(--sand);
  object-fit: cover;
}

.frame-card span {
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  white-space: nowrap;
}

.frame-card[aria-checked="true"] {
  border-color: var(--amber);
}

.frame-card:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

.frame-admin {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  margin-top: 10px;
}

.bt-field .bt-status {
  margin: 0 0 2px;
  color: var(--ink-soft);
  font-size: 13px;
}

.bt-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  margin-top: 10px;
}

.preview-toggle {
  display: inline-block;
  margin: 0 0 10px;
  padding: 6px 0;
  border: 0;
  background: none;
  color: var(--sand);
  font-family: var(--font-text);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.preview-toggle:hover {
  color: var(--paper);
}

.strip-wrap {
  background: #fff;
  animation: print-out 0.85s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.strip-wrap img {
  display: block;
  width: 100%;
  height: auto;
}

.result-bar {
  display: none;
}

/* Settings sheet */

.sheet {
  width: calc(100% - 24px);
  max-width: 400px;
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 0;
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sheet:focus {
  outline: none;
}

.sheet::backdrop {
  background: rgba(27, 23, 20, 0.72);
}

.sheet form {
  padding: 24px 22px;
}

.sheet .display {
  margin-bottom: 20px;
  text-align: left;
}

.field {
  display: block;
  margin: 0 0 18px;
}

.field > span,
.field legend {
  display: block;
  margin-bottom: 6px;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.4;
}

.field input[type="text"] {
  width: 100%;
  min-height: 48px;
  padding: 0 12px;
  border: 0;
  border-radius: 0;
  background: var(--sand);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 15px;
  font-weight: 500;
}

.field input[type="text"]::placeholder {
  color: rgba(27, 23, 20, 0.45);
}

fieldset.field {
  padding: 0;
  border: 0;
}

.radio {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  line-height: 1.4;
  cursor: pointer;
}

.radio input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--amber);
}

.sheet-actions {
  display: grid;
  gap: 8px;
  margin-top: 6px;
}

.sheet-actions .btn {
  width: 100%;
}

.sheet-actions .linklike {
  margin-top: 2px;
}

.sheet .print-note {
  max-width: none;
  color: var(--ink-soft);
}

/* Toast */

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  left: 16px;
  z-index: 40;
  width: fit-content;
  max-width: calc(100% - 32px);
  margin: 0 auto;
  padding: 12px 16px;
  background: var(--paper);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.4;
  animation: rise 0.25s ease-out both;
}

/* Print: only the receipt leaves the browser. */

#print-root {
  display: none;
}

@media print {
  #app,
  #settings-dialog,
  .toast {
    display: none !important;
  }

  html,
  body {
    background: #fff !important;
  }

  #print-root {
    display: block !important;
  }

  #print-root img {
    display: block;
    height: auto;
    margin: 0 auto;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* Phone */

@media (max-width: 760px) {
  .view-result {
    padding: 18px 16px 104px;
  }

  .result-layout {
    display: block;
    max-width: 440px;
  }

  .result-info {
    position: static;
    margin-bottom: 18px;
    padding-top: 0;
  }

  .result-info .display {
    font-size: 38px;
  }

  .result-info .lede {
    margin-bottom: 14px;
    font-size: 20px;
  }

  .result-info .facts {
    gap: 6px;
    margin-bottom: 10px;
  }

  .result-info .facts > div {
    gap: 16px;
  }

  .result-info .facts dt,
  .result-info .facts dd {
    font-size: 13px;
  }

  .result-actions,
  .result-info .print-note {
    display: none;
  }

  .print-dialog-mobile {
    display: inline-block;
    margin: 0 0 12px;
    padding-left: 0;
    color: var(--sand);
    text-align: left;
  }

  .print-dialog-mobile:hover {
    color: var(--paper);
  }

  .result-info .bt-status {
    margin: 8px 0 10px;
    font-size: 12px;
  }

  .result-preview {
    margin: 0 auto;
  }

  .preview-toggle {
    margin-top: 2px;
  }

  .result-bar {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 20;
    display: flex;
    gap: 8px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    background: var(--paper);
  }

  .result-bar .btn-primary {
    flex: 1;
    min-height: 52px;
  }

  .result-bar .icon-btn {
    width: 52px;
    height: 52px;
    flex: 0 0 52px;
    background: var(--sand);
  }

  .result-bar .icon-btn:hover {
    background: var(--sand-deep);
  }

  .receipt {
    padding-right: 20px;
    padding-left: 20px;
  }

  .receipt-camera {
    padding: 12px 12px 22px;
  }

  .camera-title {
    font-size: 22px;
  }
}

@media (max-width: 360px) {
  .receipt {
    padding-right: 16px;
    padding-left: 16px;
  }

  .display {
    font-size: 42px;
  }

  .lede {
    font-size: 22px;
  }
}

/* Motion */

.receipt-start header,
.receipt-start .facts > div,
.receipt-start .btn-primary,
.receipt-start .linklike,
.receipt-start .privacy {
  animation: rise 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.receipt-start header {
  animation-delay: 0.05s;
}

.receipt-start .facts > div:nth-child(1) {
  animation-delay: 0.14s;
}

.receipt-start .facts > div:nth-child(2) {
  animation-delay: 0.2s;
}

.receipt-start .facts > div:nth-child(3) {
  animation-delay: 0.26s;
}

.receipt-start .btn-primary {
  animation-delay: 0.33s;
}

.receipt-start .linklike {
  animation-delay: 0.4s;
}

.receipt-start .privacy {
  animation-delay: 0.46s;
}

.view-result:not([hidden]) .result-info {
  animation: rise 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.view-result:not([hidden]) .preview-toggle {
  animation: rise 0.45s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

@keyframes receipt-in {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes count-pop {
  from {
    opacity: 0.35;
    transform: scale(0.82);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes flash {
  0% {
    opacity: 0;
  }
  18% {
    opacity: 0.92;
  }
  100% {
    opacity: 0;
  }
}

@keyframes print-out {
  from {
    clip-path: inset(0 0 100% 0);
  }
  to {
    clip-path: inset(0 0 0 0);
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
