/* demo.css: the hero's live demo (W2), the only place for tenant colours; its controls stay
   ink (section 1, ADR 0024). In the phone
   calc(16 * var(--u)) is 16 dp; text boxes are 1.364 em, Nunito's ascent + descent
   (trimmed, as in Compose). */

/* 1. Layout */
/* Phone, then controls; side by side from 40em; from 64em in 8–12 (README, The demo). */
.demo {
  /* deriveTheme('#7A1F2B'), the sample's colours; demo.js sets them. */
  --a-primary: #A13C46;
  --a-on-primary: #FDFEFF;
  --a-tertiary: #95491C;
  /* ADR 0024: the visitor's colour is the only colour beside the phone, so the page's blue
     roles are ink here and the controls look as they did before the mark's blue. */
  --action: var(--ink);
  --action-hover: var(--ink-hover);
  --action-pressed: var(--ink);
  --on-action: var(--porcelain);
  --link: var(--ink);
  --link-tint: var(--ink-tint);
  --focus: var(--ink);
  --accent: var(--ink);
  --vh: 100vh;
  --cluster-gap: var(--space-2) var(--space-5);
  --phone-room: 2rem; /* viewport height left free besides the header */
  --phone-max: min(21.5rem, max(15rem, (var(--vh) - var(--header-h) - var(--phone-room)) / 2.1));
  display: grid;
  grid-template-columns: minmax(0, 1fr); /* the phone's intrinsic size must not widen the page */
  gap: var(--space-7) var(--space-6);
  align-items: start;
}

@supports (height: 1svh) {
  .demo { --vh: 100svh; }
}

.demo:focus { outline: none; } /* a scroll target for #demo links, not a control */

.demo__stage {
  justify-self: center;
  width: 100%;
  max-width: var(--phone-max);
}

.demo__panel {
  display: grid;
  gap: var(--space-5);
  align-items: start;
  min-width: 0;
}

.demo__panel > * { max-width: 28rem; } /* fields never stretch across a wide column */

@media (min-width: 40em) {
  .demo { grid-template-columns: minmax(15rem, var(--phone-max)) minmax(13.5rem, 1fr); }
  .demo__stage { justify-self: start; }
}

@media (min-width: 40em) and (min-height: 38em) {
  .demo__stage {
    position: sticky;
    top: calc(var(--header-h) + var(--space-4));
  }
}

@supports (grid-template-rows: subgrid) {
  @media (min-width: 64em) {
    .hero__demo { grid-area: 1 / 8 / span 2 / span 5; }

    .demo {
      --phone-room: calc(clamp(2.5rem, 1rem + 5vw, 5.5rem) + 1.25rem); /* the hero's top padding */
      --col: calc((100% - 4 * var(--gutter)) / 5); /* one column of the page grid; the demo spans 5 */
      grid-template-columns: minmax(0, 1fr);
      grid-template-rows: subgrid;
      row-gap: normal; /* the hero grid's */
    }

    .demo__stage { grid-area: 1 / 1 / span 2; justify-self: end; }

    /* Under the copy, on page columns 1–7 (placed: it shares a column). */
    .demo__panel {
      grid-area: 2 / 1;
      grid-template-columns: repeat(7, minmax(0, 1fr));
      grid-template-areas:
        'title title title title title title title'
        'name name name colour colour colour colour'
        'logo logo logo colour colour colour colour'
        'type type type actions actions actions actions';
      column-gap: var(--gutter);
      width: calc(7 * var(--col) + 6 * var(--gutter));
      margin-left: calc(-7 * (var(--col) + var(--gutter)));
      padding-top: var(--space-6);
      border-top: 1px solid var(--hairline);
    }

    .demo__title { grid-area: title; }
    .demo__logo { grid-area: logo; }
    .demo__colours { grid-area: colour; }
    .demo__name { grid-area: name; }
    .demo__type { grid-area: type; }
    .demo__actions { grid-area: actions; align-self: end; } /* level with the type's select */
  }
}

/* Without subgrid, from 64em the demo takes the row under the copy. */
@supports not (grid-template-rows: subgrid) {
  @media (min-width: 64em) {
    .hero__demo { grid-column: 1 / -1; }
  }
}

/* 2. Controls */
.demo__title { margin-bottom: calc(-1 * var(--space-2)); }

.demo .field__input {
  min-height: 3rem;
  padding: 0.625rem 0.875rem;
}

.demo fieldset {
  min-inline-size: 0;
  padding: 0;
  border: 0;
}

.demo legend { padding: 0; margin-bottom: var(--space-2); }


.demo__buttons .btn--text { justify-content: start; text-align: start; }

.demo.is-dropping #demo-logo {
  border-style: dashed;
  background: var(--ink-tint);
}

.demo__swatches {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  max-width: 13.5rem;
}

.demo__swatch-label { display: block; line-height: 0; }

/* A swatch shows the app's colour (deriveTheme's primary). */
.demo__swatch {
  -webkit-appearance: none; /* iOS before 15.4 */
  appearance: none;
  width: 3rem;
  height: 3rem;
  margin: 0;
  border-radius: var(--radius-sm);
  background: var(--swatch) center / 1.25rem no-repeat;
  box-shadow: inset 0 0 0 1px rgb(34 30 25 / .14);
  cursor: pointer;
}

.demo__swatch:checked {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23FDFEFF' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
}

.demo__swatch--oxblood { --swatch: #A13C46; }
.demo__swatch--terracotta { --swatch: #A33D26; }
.demo__swatch--ochre { --swatch: #7D5800; }
.demo__swatch--olive { --swatch: #50652A; }
.demo__swatch--teal { --swatch: #006B5E; }
.demo__swatch--azulejo { --swatch: #325F9B; }
.demo__swatch--plum { --swatch: #7448A9; }
.demo__swatch--ink { --swatch: var(--ink); }

.demo__custom {
  display: flex;
  gap: var(--space-2);
  max-width: 18rem;
  margin-top: var(--space-2);
}

.demo__picker {
  flex: none;
  width: 3rem;
  height: 3rem;
  padding: 0.3125rem;
  border: 1px solid var(--ink-muted);
  border-radius: var(--radius-sm);
  background: var(--paper-brightest);
  cursor: pointer;
}

.demo__picker:hover { border-color: var(--ink); }
.demo__picker::-webkit-color-swatch-wrapper { padding: 0; }
.demo__picker::-webkit-color-swatch { border: 0; border-radius: var(--radius-xs); }
.demo__picker::-moz-color-swatch { border: 0; border-radius: var(--radius-xs); }

.demo__hex {
  position: relative;
  flex: 1;
  min-width: 0;
}

.demo__hex::before {
  content: '#';
  position: absolute;
  top: 50%;
  left: 0.875rem;
  translate: 0 -50%;
  color: var(--ink-muted);
  pointer-events: none;
}

.demo__hex .field__input {
  padding-left: 1.625rem;
  font-variant-numeric: tabular-nums lining-nums;
  text-transform: uppercase;
}

.demo__colours :is(.field__hint, .field__error) { margin-top: var(--space-2); }

.demo__note {
  color: var(--ink-muted);
  font-size: 0.875rem;
  line-height: 1.45;
}

.demo__note:not(:empty),
.demo__url { margin-top: var(--space-2); }

.demo__url { font-size: var(--text-small); }
.demo__sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* No JavaScript: only the phone's summary stays. */
@media (scripting: none) {
  .demo__panel { display: block; padding: 0; border: 0; }
  .demo__panel > :not(#demo-summary) { display: none; }
}

/* 3. The phone's screens */
.demo-screen {
  --u: calc(100cqi / 393); /* 1 dp; resolved inside this container */
  --hair: max(1px, var(--u)); /* a 1 dp hairline, never thinner than a pixel */
  position: absolute;
  z-index: 0;
  inset: 0;
  overflow: hidden;
  container-type: inline-size;
  user-select: none;
  pointer-events: none;
  -webkit-font-smoothing: auto; /* closer to the weight the app renders */
}

@supports not (width: 1cqi) {
  .demo-screen { --u: 0.78px; } /* iOS 15: no container units, so a typical phone's scale */
}

.demo-home,
.demo-splash,
.demo-app {
  position: absolute;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  font-size: calc(14 * var(--u));
  line-height: 1.364;
  transition: opacity var(--duration-s) var(--ease), visibility 0s var(--duration-s), transform 0s var(--duration-s);
}

.demo-screen[data-screen='home'] .demo-home,
.demo-screen[data-screen='splash'] .demo-splash,
.demo-screen[data-screen='app'] .demo-app {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity var(--duration-s) var(--ease), visibility 0s, transform var(--duration-m) var(--ease);
}

.demo-ico {
  flex: none;
  width: calc(24 * var(--u));
  height: calc(24 * var(--u));
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Your icon: home screen, splash and (logo only) app bar. */
.demo-tile {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  width: calc(60 * var(--u));
  height: calc(60 * var(--u));
  border-radius: calc(13.5 * var(--u));
  background: var(--a-primary);
  color: var(--a-on-primary);
  transition: transform var(--duration-xs) var(--ease);
}

.demo-tile .demo-tile__logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.demo-tile.is-contain {
  background: var(--paper-brightest);
  box-shadow: inset 0 0 0 1px rgb(34 30 25 / .08);
}

.demo-tile.is-contain .demo-tile__logo { padding: 14%; object-fit: contain; }

/* A light (reversed) logo sits on the app's colour. */
.demo-tile.is-contain.is-light { background: var(--a-primary); box-shadow: none; }

.demo-tile__mono {
  font-size: calc(22 * var(--u));
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* 4. Home screen: neutral placeholders, so your icon is the only colour */
.demo-home { background: var(--hairline); }

.demo-home__grid {
  position: absolute;
  top: calc(74 * var(--u));
  right: calc(34 * var(--u));
  left: calc(34 * var(--u));
  display: grid;
  grid-template-columns: repeat(4, calc(60 * var(--u)));
  justify-content: space-between;
  row-gap: calc(22 * var(--u));
}

.demo-home__app {
  display: grid;
  justify-items: center;
  gap: calc(6 * var(--u));
}

.demo-home__icon {
  position: relative;
  width: calc(60 * var(--u));
  height: calc(60 * var(--u));
  border-radius: calc(13.5 * var(--u));
  background: var(--paper-brightest);
}

.demo-home__icon::before {
  content: '';
  position: absolute;
  inset: 32%;
  border-radius: 50%;
  background: var(--hairline);
}

.demo-home__icon--b { background: var(--ink-muted); }
.demo-home__icon--b::before { inset: 30% 22%; border-radius: calc(3 * var(--u)); background: var(--paper-brightest); }
.demo-home__icon--c { background: var(--porcelain); }
.demo-home__icon--c::before { inset: 28%; border: calc(4 * var(--u)) solid var(--ink-muted); background: none; }
.demo-home__icon--d { background: var(--ink); }
.demo-home__icon--d::before { inset: 26% 46% 26% 26%; border-radius: calc(3 * var(--u)); background: var(--bone); }
.demo-home__icon--e::before { inset: 34% 18% 34% 18%; border-radius: calc(3 * var(--u)); }
.demo-home__icon--f { background: var(--bone); }
.demo-home__icon--f::before { inset: 22% 22% 50% 50%; border-radius: 0 0 0 100%; background: var(--ink-muted); }
.demo-home__icon--g::before { inset: 25%; border: calc(4 * var(--u)) solid var(--hairline); background: none; }
.demo-home__icon--h { background: var(--paper); }
.demo-home__icon--h::before { inset: 30%; border-radius: calc(4 * var(--u)); background: var(--ink-muted); }

/* A 2 × 2 clock widget at 10:30, the time in the status bar. */
.demo-home__widget {
  display: grid;
  grid-area: span 2 / span 2;
  justify-items: center;
  align-content: start;
  gap: calc(6 * var(--u));
}

.demo-home__clock {
  position: relative;
  width: calc(148 * var(--u));
  height: calc(148 * var(--u));
  border-radius: calc(26 * var(--u));
  background: var(--paper-brightest);
}

.demo-home__clock::before,
.demo-home__clock::after {
  content: '';
  position: absolute;
  bottom: 50%;
  left: calc(50% - 2.5 * var(--u));
  width: calc(5 * var(--u));
  border-radius: calc(3 * var(--u));
  background: var(--ink);
  transform-origin: 50% calc(100% - 2.5 * var(--u));
}

.demo-home__clock::before { height: calc(34 * var(--u)); rotate: 315deg; } /* hour hand */
.demo-home__clock::after { height: calc(52 * var(--u)); rotate: 180deg; }

.demo-home__label {
  width: calc(36 * var(--u));
  height: calc(5 * var(--u));
  margin-block: calc(4 * var(--u));
  border-radius: calc(2 * var(--u));
  background: rgb(34 30 25 / .16);
}

.demo-home__name {
  max-width: calc(76 * var(--u));
  overflow: hidden;
  color: var(--ink-text);
  font-size: calc(11 * var(--u));
  font-weight: 500;
  line-height: calc(13 * var(--u));
  text-overflow: ellipsis;
  white-space: nowrap;
}

.demo-screen.is-tapping .demo-home__app--you .demo-tile { transform: scale(.9); }

.demo-home__dots {
  position: absolute;
  bottom: calc(132 * var(--u));
  left: 50%;
  width: calc(6 * var(--u));
  height: calc(6 * var(--u));
  margin-left: calc(-8 * var(--u));
  border-radius: 50%;
  background: var(--ink-text);
  box-shadow: calc(10 * var(--u)) 0 0 rgb(34 30 25 / .28);
}

.demo-home__dock {
  position: absolute;
  inset: auto calc(12 * var(--u)) calc(24 * var(--u));
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: calc(92 * var(--u));
  padding-inline: calc(22 * var(--u));
  border-radius: calc(32 * var(--u));
  background: var(--bone);
}

/* 5. Splash: it grows from your icon, its corners (88 dp × 0.16) like the icon's */
.demo-splash {
  display: grid;
  place-items: center;
  border-radius: calc(88 * var(--u));
  background: var(--a-primary);
  transform: scale(.16);
  transform-origin: 83.7% 35.9%; /* the centre of your icon on the home screen */
}

.demo-screen[data-screen='splash'] .demo-splash {
  border-radius: calc(46 * var(--u));
  transition: opacity var(--duration-s) var(--ease), visibility 0s, transform var(--duration-m) var(--ease), border-radius var(--duration-m) var(--ease);
}

.demo-splash .demo-tile {
  width: calc(104 * var(--u));
  height: calc(104 * var(--u));
  border-radius: calc(23 * var(--u));
  background: var(--paper-brightest);
  color: var(--a-primary);
}

.demo-splash .demo-tile__mono { font-size: calc(38 * var(--u)); }

/* 6. The client app's home (HomeScreen.kt) */
.demo-app {
  background: var(--porcelain);
  color: var(--ink-text);
  transform: translateY(calc(8 * var(--u)));
}

.demo-app__bar {
  position: absolute;
  inset: calc(54 * var(--u)) 0 auto;
  display: flex;
  align-items: center;
  gap: calc(10 * var(--u));
  height: calc(56 * var(--u) + var(--hair)); /* the 56 dp bar and its hairline */
  padding: 0 calc(12 * var(--u)) 0 calc(16 * var(--u));
  border-bottom: var(--hair) solid var(--hairline-faint);
}

.demo-app__title {
  min-width: 0;
  overflow: hidden;
  font-size: calc(20 * var(--u));
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.demo-tile--bar {
  flex: none;
  width: calc(28 * var(--u));
  height: calc(28 * var(--u));
  border-radius: calc(6 * var(--u));
}

.demo-app__body {
  position: absolute;
  inset: calc(110 * var(--u) + var(--hair)) calc(16 * var(--u)) auto;
  display: flex;
  flex-direction: column;
  gap: calc(16 * var(--u));
  padding-top: calc(16 * var(--u));
}

.demo-app__greeting { font-size: calc(24 * var(--u)); font-weight: 500; }

.demo-app__rule {
  display: block;
  width: calc(24 * var(--u));
  height: var(--hair);
  margin: calc(8 * var(--u)) 0 calc(9 * var(--u) - var(--hair));
  background: var(--a-tertiary);
}

.demo-app__subtitle,
.demo-app__next-with {
  color: var(--ink-muted);
  letter-spacing: calc(.1 * var(--u));
}

.demo-app__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: calc(12 * var(--u));
}

/* RzervdCard: the border is drawn inside the 16 dp padding, as in Compose. */
.demo-app__card {
  border: var(--hair) solid var(--hairline);
  border-radius: calc(14 * var(--u));
  background: var(--paper-brightest);
  box-shadow: 0 calc(2 * var(--u)) calc(8 * var(--u)) rgb(34 30 25 / .08);
}

.demo-app__quick,
.demo-app__next {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: calc(16 * var(--u) - var(--hair));
}

.demo-ico--accent { margin-bottom: calc(16 * var(--u)); color: var(--a-primary); }

.demo-app__quick-title,
.demo-app__next-title,
.demo-app__service-name {
  font-size: calc(15 * var(--u));
  font-weight: 600;
}

.demo-app__quick-hint,
.demo-app__when,
.demo-app__meta {
  color: var(--ink-muted);
  font-size: calc(12 * var(--u));
  letter-spacing: calc(.1 * var(--u));
}

.demo-app__quick-hint,
.demo-app__next-with { margin-top: calc(4 * var(--u)); }

.demo-app__book {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: calc(8 * var(--u));
  height: calc(52 * var(--u));
  border-radius: calc(10 * var(--u));
  background: var(--a-primary);
  color: var(--a-on-primary);
  font-weight: 500;
  letter-spacing: calc(.2 * var(--u));
}

.demo-app__book .demo-ico { width: calc(20 * var(--u)); height: calc(20 * var(--u)); }

.demo-app__eyebrow {
  margin: calc(8 * var(--u)) 0 calc(-8 * var(--u));
  color: var(--ink-muted);
  font-size: calc(11 * var(--u));
  font-weight: 500;
  letter-spacing: calc(.8 * var(--u));
  text-transform: uppercase;
}

.demo-app__when {
  display: flex;
  align-items: center;
  gap: calc(4 * var(--u));
  min-height: calc(16 * var(--u));
  margin-top: calc(8 * var(--u));
}

.demo-app__when .demo-ico { width: calc(16 * var(--u)); height: calc(16 * var(--u)); }

.demo-app__popular {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: calc(52 * var(--u));
}

.demo-app__all {
  padding-right: calc(24 * var(--u));
  color: var(--a-primary);
  font-size: calc(14 * var(--u));
  letter-spacing: calc(.2 * var(--u));
  text-transform: none;
}

.demo-app__services { display: flex; flex-direction: column; gap: calc(8 * var(--u)); }

.demo-app__service {
  display: flex;
  align-items: center;
  padding: calc(16 * var(--u) - var(--hair));
}

.demo-app__service > .demo-ico {
  margin: calc(12 * var(--u)) calc(24 * var(--u)) calc(12 * var(--u)) calc(12 * var(--u)); /* a 48 dp slot */
  color: var(--ink-muted);
}

.demo-app__service-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.demo-app__price { margin-left: calc(12 * var(--u)); font-size: calc(20 * var(--u)); font-weight: 600; white-space: nowrap; }

/* bodySmall's 17 dp lines, outer half-leading trimmed as in Compose. */
.demo-app__meta { line-height: calc(17 * var(--u)); margin-block: calc(-0.316 * var(--u)); }

.demo-app__nav {
  position: absolute;
  inset: auto 0 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: calc(114 * var(--u) + var(--hair)); /* hairline, 80 dp bar, 34 dp home-indicator inset */
  padding: 0 calc(8 * var(--u)) calc(34 * var(--u));
  border-top: var(--hair) solid var(--hairline-faint);
  background: var(--porcelain);
}

.demo-app__tab {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(4 * var(--u));
  color: var(--ink-muted);
  font-size: calc(12 * var(--u));
  font-weight: 500;
  letter-spacing: calc(.3 * var(--u));
}

.demo-app__tab--on { color: var(--ink-text); }
.demo-app__tab--on .demo-ico { color: var(--a-primary); }

/* The ink dot under the selected tab. */
.demo-app__tab--on::after {
  content: '';
  position: absolute;
  top: calc(64 * var(--u));
  left: 50%;
  width: calc(4 * var(--u));
  height: calc(4 * var(--u));
  margin-left: calc(-2 * var(--u));
  border-radius: 50%;
  background: var(--a-primary);
}

/* Forced colours: a swatch's colour is its content; the phone is a picture. */
@media (forced-colors: active) {
  .phone,
  .demo__swatch { forced-color-adjust: none; }

  .demo__swatch { border: 1px solid CanvasText; }
}
