/* Cosy Home: page chrome around the Colorfigures cutaway. */

:root {
  --paper: #efe3cd;
  --paper-soft: #f6ecda;
  --ink: #231e16;
  --muted: #746958;
  --rule: #d9cbb1;
  --accent: #b55f43;
  --sage: #617a56;
  --focus: #175f67;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background-color: #e9dcc4;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='320' height='320'><filter id='p'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .44  0 0 0 0 .40  0 0 0 0 .33  .14 0 0 0 0'/></filter><rect width='100%' height='100%' filter='url(%23p)'/></svg>");
  color: var(--ink);
  font: 15px/1.4 ui-rounded, ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden;
  touch-action: manipulation;
}

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

button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  inset: 8px auto auto 8px;
  z-index: 20;
  transform: translateY(-160%);
  padding: 10px 14px;
  border: 2px solid var(--ink);
  background: var(--paper-soft);
  color: var(--ink);
  font-weight: 700;
}

.skip-link:focus {
  transform: none;
}

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

.toy {
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-height: 100svh;
  padding: 12px clamp(10px, 2vw, 24px) 14px;
  max-width: 1440px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

h1 {
  margin: 0;
  font: 700 clamp(24px, 3vw, 36px)/1 ui-rounded, ui-sans-serif, -apple-system, "Segoe UI", sans-serif;
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 44px;
  color: var(--muted);
  font-size: 14px;
}

.crumbs button {
  min-width: 44px;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  cursor: pointer;
}

.crumbs [aria-current="page"] {
  color: var(--muted);
}

.navigation {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.floors,
.rooms {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.floors {
  flex: none;
  padding: 2px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: rgba(255, 248, 233, 0.62);
}

.rooms {
  padding: 2px 2px 4px;
}

.floors::-webkit-scrollbar,
.rooms::-webkit-scrollbar {
  display: none;
}

.floor,
.room {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: none;
  min-height: 44px;
  padding: 0 14px;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  background: var(--paper-soft);
  color: var(--ink);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

.floor {
  min-width: 44px;
  padding-inline: 12px;
  border-color: transparent;
  background: transparent;
  font-size: 13px;
}

.room svg {
  width: 22px;
  height: 22px;
  flex: none;
}

.floor:hover,
.room:hover {
  background: #fff8e9;
}

.floor:active,
.room:active {
  transform: scale(0.97);
}

.floor[aria-pressed="true"],
.room[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper-soft);
}

.stage {
  position: relative;
  /* The height is set in script to match the drawing's own shape, so a wide
     house view fills the frame instead of being letterboxed into the middle
     of a tall box. `flex: none` keeps the script's height from being
     overridden by the flex column. */
  flex: none;
  width: 100%;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: #f5ead6;
  overflow: hidden;
}

#house {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  user-select: none;
}

#house [data-act] {
  cursor: pointer;
}

#labels text {
  fill: var(--ink);
  paint-order: stroke;
  stroke: #f5ead6;
  stroke-width: 4px;
  stroke-linejoin: round;
  font: 700 13px/1 ui-rounded, ui-sans-serif, -apple-system, "Segoe UI", sans-serif;
  pointer-events: none;
}

#labels .floor-label {
  fill: var(--accent);
  font-size: 12px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

/* The floor names for the whole-house view. They live in HTML rather than in
   the drawing, so the house can fill the whole frame instead of giving up
   a strip of width to make room for them. */
.legend {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 1;
  display: grid;
  gap: 3px;
  margin: 0;
  padding: 8px 12px 8px 30px;
  list-style: none;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: rgba(255, 248, 233, 0.9);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  pointer-events: none;
}

.legend[hidden] {
  display: none;
}

.legend li {
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.legend b {
  color: var(--accent);
  font-weight: 800;
  letter-spacing: 0.08em;
}

.doing {
  display: flex;
  align-items: end;
  gap: 14px;
  min-height: 60px;
}

.doing__head {
  flex: none;
  min-width: 130px;
}

.doing h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 750;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.doing__btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
}

.doing__empty {
  margin: 0;
  align-self: center;
  color: var(--muted);
  font-size: 14px;
}

.do {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 16px;
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  background: var(--paper-soft);
  color: var(--ink);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  box-shadow: 2px 2px 0 rgba(35, 30, 22, 0.85);
}

.do svg {
  width: 24px;
  height: 24px;
  flex: none;
}

.do:hover {
  background: #fff8e9;
}

.do:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}

.doing__note {
  margin: 0;
  min-height: 1.2em;
  color: var(--muted);
  font-size: 14px;
}

.credit {
  padding-top: 8px;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 12.5px;
}

.credit a {
  color: var(--muted);
}

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

.appliance-dialog {
  width: min(1060px, calc(100vw - 32px));
  max-width: none;
  max-height: min(820px, calc(100dvh - 32px));
  padding: clamp(16px, 3vw, 30px);
  border: 1.5px solid var(--ink);
  border-radius: 12px;
  background: #f6ecda;
  color: var(--ink);
  box-shadow: 0 22px 70px rgba(35, 30, 22, 0.24);
}

.appliance-dialog::backdrop {
  background: rgba(35, 30, 22, 0.58);
  backdrop-filter: blur(2px);
}

.dialog__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog__crumb {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.04em;
}

.close {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-left: auto;
  padding: 0;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  background: var(--paper-soft);
  color: var(--ink);
  font: 500 34px/1 ui-rounded, sans-serif;
  cursor: pointer;
}

.close:hover {
  background: var(--ink);
  color: var(--paper-soft);
}

.appliance-dialog h2 {
  margin: 8px 0 14px;
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1;
}

.appliance-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(250px, 0.75fr);
  gap: clamp(18px, 3vw, 38px);
  align-items: center;
}

.appliance-visual {
  min-width: 0;
  min-height: min(54vh, 470px);
  display: grid;
  place-items: center;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: #fff7e8;
  overflow: hidden;
}

#applianceSvg {
  display: block;
  width: 100%;
  height: min(50vh, 440px);
}

.appliance-panel {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 20px;
}

.appliance-status {
  min-height: 3em;
  margin: 0;
  color: var(--muted);
}

.appliance-controls {
  display: grid;
  gap: 10px;
}

.appliance-control {
  min-height: 50px;
  padding: 11px 14px;
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  background: #fff8e9;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.appliance-control:hover:not(:disabled) {
  background: var(--ink);
  color: var(--paper-soft);
}

.appliance-control:disabled {
  border-color: var(--rule);
  color: var(--muted);
  cursor: not-allowed;
}

@media (max-width: 760px) {
  .toy {
    gap: 7px;
    padding: 8px 10px 10px;
  }

  .topbar {
    min-height: 44px;
  }

  h1 {
    font-size: 26px;
  }

  .navigation {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
  }

  .floors {
    align-self: flex-start;
  }

  .doing {
    align-items: start;
    flex-direction: column;
    gap: 6px;
  }

  .doing__head {
    width: 100%;
    min-width: 0;
  }

  .doing__btns {
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 3px;
  }

  .do {
    flex: none;
  }

  .credit {
    display: none;
  }

  .appliance-dialog {
    width: calc(100vw - 20px);
    max-height: calc(100dvh - 20px);
    padding: 14px;
  }

  .appliance-dialog h2 {
    margin-block: 3px 10px;
    font-size: 28px;
  }

  .appliance-layout {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .appliance-visual {
    min-height: 0;
  }

  #applianceSvg {
    height: min(36dvh, 290px);
  }

  .appliance-panel {
    gap: 10px;
  }

  .appliance-status {
    min-height: 2.8em;
    font-size: 14px;
  }

  .appliance-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .appliance-control {
    min-height: 44px;
    text-align: center;
  }
}

@media (max-height: 620px) and (min-width: 761px) {
  .toy {
    gap: 5px;
    padding-block: 7px;
  }

  .stage {
    min-height: 320px;
  }

  .doing {
    min-height: 50px;
  }

  .credit {
    display: none;
  }
}

@media (max-width: 560px) {
  .room {
    min-height: 44px;
    padding: 0 12px;
    font-size: 14px;
  }

  .do {
    min-height: 46px;
    padding: 0 13px;
    font-size: 14px;
  }
}

.floor,
.room,
.do,
.close,
.appliance-control {
  transition: none;
}

@media (prefers-reduced-motion: no-preference) {
  .floor,
  .room,
  .do {
    transition: background 0.14s ease, transform 0.14s ease;
  }
}

@media (prefers-reduced-motion: reduce) {
  .floor:active,
  .room:active,
  .do:active,
  .close:active {
    transform: none;
  }
}
