/*
 * tokens.css — the "Organic" design system, as imported from the Claude Design
 * project "Desktop Pet Application UI Mockups".
 *
 * This is the source of truth for the look of every real window (dock, popover,
 * settings). The tokens are reproduced from the design's ds/styles.css; the two
 * changes made for a shipping desktop app are:
 *
 *   1. Fonts are bundled locally as woff2 rather than pulled from Google Fonts.
 *      An Electron window with a strict CSP can't reach the network, and a pet
 *      app shouldn't phone home to render its own UI.
 *   2. A `.drag` / `.no-drag` pair is added for -webkit-app-region, since these
 *      are real frameless OS windows rather than divs in a mockup.
 */

@font-face {
  font-family: 'Caprasimo';
  font-style: normal;
  font-weight: 400;
  font-display: block;
  src: url('../assets/fonts/Caprasimo-latin.woff2') format('woff2');
}

@font-face {
  font-family: 'Figtree';
  font-style: normal;
  font-weight: 400 700;
  font-display: block;
  src: url('../assets/fonts/Figtree-latin.woff2') format('woff2');
}

:root {
  --color-bg: #f5ead8;
  --color-surface: #ebddc5;
  --color-text: #201e1d;
  --color-accent: #c67139;
  --color-accent-2: #7a8a5e;
  --color-divider: color-mix(in srgb, #201e1d 16%, transparent);

  /* Tonal ramps — generated in OKLCH on one shared lightness scale, so the
     same step of any role matches the others in visual value. */
  --color-neutral-100: #f9f4ed;
  --color-neutral-200: #eee7db;
  --color-neutral-300: #dcd3c4;
  --color-neutral-400: #c0b6a5;
  --color-neutral-500: #a19786;
  --color-neutral-600: #82796a;
  --color-neutral-700: #645c50;
  --color-neutral-800: #474238;
  --color-neutral-900: #2e2b25;

  --color-accent-100: #fff2eb;
  --color-accent-200: #ffe1d0;
  --color-accent-300: #ffc6a5;
  --color-accent-400: #f6a06b;
  --color-accent-500: #d67f48;
  --color-accent-600: #b2622d;
  --color-accent-700: #8c491a;
  --color-accent-800: #643312;
  --color-accent-900: #402310;

  --color-accent-2-100: #f0fae1;
  --color-accent-2-200: #e1eecc;
  --color-accent-2-300: #ccdbb2;
  --color-accent-2-400: #aebf92;
  --color-accent-2-500: #8fa073;
  --color-accent-2-600: #728157;
  --color-accent-2-700: #56633f;
  --color-accent-2-800: #3d472b;
  --color-accent-2-900: #272e1b;

  --font-heading: 'Caprasimo', system-ui, sans-serif;
  --font-heading-weight: 400;
  --font-body: 'Figtree', system-ui, sans-serif;

  --space-1: 4.4px;
  --space-2: 8.8px;
  --space-3: 13.2px;
  --space-4: 17.6px;
  --space-6: 26.4px;
  --space-8: 35.2px;

  /* Windows are frameless and draw their own corner, so it has to be the one
     macOS uses (~10pt since Big Sur) or it reads as the wrong shape sitting on
     the desktop. The design's own 28px stays for cards *inside* a window. */
  --radius-window: 10px;
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 28px;

  --shadow-sm: 0 1px 2px color-mix(in srgb, #2e2b25 14%, transparent);
  --shadow-md: 0 3px 10px color-mix(in srgb, #2e2b25 16%, transparent);
  --shadow-lg: 0 12px 32px color-mix(in srgb, #2e2b25 22%, transparent);
}

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

html,
body {
  margin: 0;
  height: 100%;
  /* Frameless windows are transparent; each window paints its own panel. */
  background: transparent;
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  font-weight: 400;
  user-select: none;
  -webkit-user-select: none;
  cursor: default;
  overflow: hidden;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: var(--font-heading-weight);
  line-height: 1.12;
  letter-spacing: -0.015em;
  margin: 0 0 var(--space-2);
}
h3 { font-size: 25px; }
h4 { font-size: 20px; }
p { margin: 0 0 var(--space-3); }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--color-accent) 30%, transparent); }

.text-muted { color: color-mix(in srgb, var(--color-text) 55%, transparent); }

/* — frameless window drag regions — */
.drag { -webkit-app-region: drag; }
.no-drag { -webkit-app-region: no-drag; }

/* — buttons — */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  text-decoration: none;
  font-family: var(--font-heading);
  font-weight: var(--font-heading-weight);
  font-size: 14px;
  line-height: 1.2;
  color: var(--color-text);
  background: transparent;
  border: 1px solid transparent;
  padding: var(--space-2) calc(var(--space-3) * 1.2);
  border-radius: 999px;
  -webkit-app-region: no-drag;
}
.btn svg { display: block; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--color-accent); color: var(--color-bg); }
.btn-primary:hover:not(:disabled) { background: var(--color-accent-600); }
.btn-primary:active:not(:disabled) { background: var(--color-accent-700); }
.btn-secondary { border-color: var(--color-divider); }
.btn-secondary:hover:not(:disabled) { background: color-mix(in srgb, var(--color-text) 7%, transparent); }
.btn-secondary:active:not(:disabled) { background: color-mix(in srgb, var(--color-text) 14%, transparent); }
.btn-icon { width: 36px; height: 36px; padding: 0; }

/* — forms — */
.field > label {
  display: block;
  font-size: 12px;
  margin-bottom: 5px;
  color: color-mix(in srgb, var(--color-text) 70%, transparent);
}
.input {
  width: 100%;
  min-height: 36px;
  padding: 6px 14px;
  font: inherit;
  font-size: 14px;
  color: var(--color-text);
  caret-color: var(--color-accent);
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: 999px;
  user-select: text;
  -webkit-user-select: text;
  -webkit-app-region: no-drag;
}
.input:hover { border-color: color-mix(in srgb, var(--color-text) 45%, transparent); }
.input:focus-visible { border-color: var(--color-accent); outline-offset: 0; }

/* — cards — */
.card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3);
  border-radius: calc(var(--radius-lg) * 1.15);
  background: var(--color-surface);
}

/*
 * The pet avatar. `position: relative` matters: the costume overlay is absolute
 * and must resolve against the puck, not against whatever panel contains it.
 */
.puck {
  position: relative;
  display: block;
  border-radius: 999px;
}
.puck canvas { display: block; border-radius: 999px; }
.costume { position: absolute; pointer-events: none; }

/* — the toggle used across every panel — */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2);
  border-radius: var(--radius-md);
  cursor: pointer;
  -webkit-app-region: no-drag;
}
.toggle-row:hover { background: color-mix(in srgb, var(--color-accent) 10%, transparent); }
.toggle-row > span:first-child {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 14px;
}
.switch {
  width: 42px;
  height: 24px;
  border-radius: 999px;
  flex: none;
  position: relative;
  transition: background 0.18s;
  background: var(--color-neutral-300);
}
.switch.on { background: var(--color-accent); }
.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--color-bg);
  box-shadow: var(--shadow-sm);
  transition: left 0.18s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.switch.on::after { left: 21px; }


/* — quick controls, shared by the menu-bar panel and the room's side panel —
 *
 * These carry `pop-` names because the panel is where they started, but both
 * surfaces are built by `ui/quick-controls.js` and so need the same rules. They
 * live here, in the stylesheet every window loads, rather than in popover.css
 * where only one of the two could see them. */

.pop-id {
  flex: 1;
  min-width: 0;
}
.pop-name {
  font-family: var(--font-heading);
  font-size: 16px;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pop-state {
  font-size: 11px;
  color: var(--color-accent-700);
}
.pop-card {
  margin-top: var(--space-3);
  padding: var(--space-2) var(--space-3) var(--space-3);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--color-surface) 70%, transparent);
  flex: none;
}
.pop-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: var(--space-2);
}
.pop-card-label {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.7;
}
.pop-card-value {
  font-size: 11px;
  font-weight: 700;
  color: var(--color-accent-700);
}
.pop-card input[type='range'] {
  width: 100%;
  accent-color: var(--color-accent);
  cursor: pointer;
}
.pop-scale {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  opacity: 0.5;
  margin-top: 2px;
}
.pop-toggles {
  margin-top: var(--space-2);
  gap: 1px;
  display: flex;
  flex-direction: column;
  flex: none;
}
.pop-section {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-divider);
  flex: none;
}
.pop-section[hidden] { display: none !important; }
.pop-section-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-accent-700);
  opacity: 0.85;
  margin-bottom: var(--space-2);
}
.pop-section-body { display: flex; flex-direction: column; }
.pop-section-body .pop-wide:first-child { margin-top: 0; }
.pop-wide {
  width: 100%;
  margin-top: var(--space-2);
  font-size: 12.5px;
  padding: 6px var(--space-3);
  border-color: var(--color-divider);
}
.pop-wide.is-active {
  background: color-mix(in srgb, var(--color-accent) 18%, transparent);
  border-color: color-mix(in srgb, var(--color-accent) 45%, transparent);
  color: var(--color-accent-700);
}
/* Centred, like every other full-width button in the panel. It was left-aligned
   back when it carried an icon; the label goes it alone now. */
.pop-home {
  gap: 0;
  background: color-mix(in srgb, var(--color-accent-2) 16%, transparent);
  border-color: color-mix(in srgb, var(--color-accent-2) 40%, transparent);
}
.pop-home:hover:not(:disabled) {
  background: color-mix(in srgb, var(--color-accent-2) 28%, transparent);
}

/* — end actions, shared by the panel and the room's side panel — */

/* Removing a pet and quitting are both endings, and neither is something you
   should hit while reaching for "Off to bed" — so they sit below the divider,
   quiet, at the extremes of the row. */
.pop-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding-top: var(--space-2);
  border-top: 1px solid var(--color-divider);
  flex: none;
}
.pop-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  max-width: 60%;
  padding: 4px var(--space-2);
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-family: var(--font-body);
  font-size: 11.5px;
  font-weight: 600;
  color: color-mix(in srgb, var(--color-text) 62%, transparent);
  cursor: pointer;
  -webkit-app-region: no-drag;
}
.pop-link svg { flex: none; }
.pop-link > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pop-link:hover:not(:disabled) {
  background: color-mix(in srgb, var(--color-text) 8%, transparent);
  color: var(--color-text);
}
.pop-link:disabled { opacity: 0.35; cursor: not-allowed; }
/* Matches the room's remove control rather than inventing a red the design
   system doesn't have. */
.pop-link-warn { color: var(--color-accent-700); }
.pop-link-warn:hover:not(:disabled) {
  background: color-mix(in srgb, var(--color-accent) 14%, transparent);
  color: var(--color-accent-700);
}



/* — shared animations from the design — */
@keyframes breathe {
  0%, 100% { transform: scale(1, 1); }
  50% { transform: scale(1.03, 0.97); }
}
@keyframes zzz {
  0% { opacity: 0; transform: translate(0, 0) scale(0.6); }
  25% { opacity: 0.85; }
  100% { opacity: 0; transform: translate(18px, -30px) scale(1.1); }
}
@keyframes popIn {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-8px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
