/* The drawing canvas that turns sketches into perfect shapes. A dark app frame holds a sheet of warm paper with a
   faint grid; the strokes live on one canvas laid on the paper, the pill and the pencil are DOM on top of it. The
   frame (.sk__card) is moved only by GSAP, its children only by CSS. */
:root {
  --page: #0b0c10;              /* the page */
  --halo: rgba(98, 112, 255, 0.22); /* the soft light behind the app */
  --frame: #17181d;             /* the app frame */
  --frame-low: #111216;         /* the frame, lower down */
  --edge: rgba(255, 255, 255, 0.09); /* the frame's 1px edge */
  --paper: #f6f3ec;             /* the sheet */
  --grid: rgba(28, 30, 40, 0.055); /* the grid on the sheet */
  --ink: #23252d;               /* the pencil */
  --accent: #4b5bff;            /* a snapped shape, the switch, the pill's bar */
  --text: #eceef5;              /* words on the frame */
  --muted: rgba(236, 238, 245, 0.5); /* small words on the frame */
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--text);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* a very fine grain over the whole page */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

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

.stage {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 12px;
  overflow: hidden;
}

.sk {
  position: relative;
  display: grid;
  place-items: center;
}

.sk__halo {
  position: absolute;
  inset: -12% -18%;
  background:
    radial-gradient(48% 40% at 50% 38%, var(--halo), transparent 70%),
    radial-gradient(30% 26% at 72% 82%, rgba(255, 196, 140, 0.07), transparent 70%);
  filter: blur(20px);
  pointer-events: none;
}

.sk__card {
  position: relative;
  width: min(92vw, 560px, 122vh);
  height: min(88vh, 470px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 6px 8px 0;
  border-radius: 26px;
  background: linear-gradient(180deg, var(--frame), var(--frame-low));
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.6),
    0 1px 0 0 rgba(255, 255, 255, 0.06) inset,
    0 2px 4px rgba(0, 0, 0, 0.3),
    0 18px 40px -12px rgba(0, 0, 0, 0.7),
    0 50px 90px -30px rgba(20, 24, 70, 0.55);
}

/* the frame's edge catches the light only on top */
.sk__card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), var(--edge) 30%, rgba(255, 255, 255, 0.02));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.sk__bar {
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 4px 0 6px;
  min-width: 0;
}

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

.sk__logo {
  width: 22px;
  height: 22px;
  flex: none;
}

.sk__logo-bg {
  fill: var(--accent);
}

.sk__logo-line {
  fill: none;
  stroke: #fff;
  stroke-width: 2;
  stroke-linecap: round;
}

.sk__file {
  font-size: 13px;
  font-weight: 560;
  font-stretch: 104%;
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sk__muted {
  color: var(--muted);
  font-weight: 450;
}

.sk__actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

.sk__zoom {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  padding: 4px 7px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.sk__icon-btn {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background-color 0.2s, transform 0.25s cubic-bezier(0.3, 1.6, 0.5, 1);
}

.sk__icon-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sk__icon-btn:active {
  transform: scale(0.9);
}

.sk__icon-btn:focus-visible,
.sk__tool:focus-visible,
.sk__snap:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* the sheet */
.sk__paper {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  touch-action: none;
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px),
    radial-gradient(120% 90% at 30% 0%, rgba(255, 255, 255, 0.7), transparent 60%);
  background-size: 22px 22px, 22px 22px, 100% 100%;
  background-position: -1px -1px, -1px -1px, 0 0;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.5),
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 -14px 30px -18px rgba(60, 50, 30, 0.18) inset;
}

/* the paper's own fine tooth */
.sk__paper::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.18;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.3' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.45 0 0 0 0 0.4 0 0 0 0 0.32 0 0 0 0.5 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23p)'/%3E%3C/svg%3E");
}

@media (hover: hover) and (pointer: fine) {
  .sk__paper {
    cursor: none;
  }

  .sk__icon-btn:hover {
    background: rgba(255, 255, 255, 0.07);
  }

  .sk__tool:hover {
    color: var(--text);
  }

  .sk__snap:hover {
    background: rgba(255, 255, 255, 0.07);
  }
}

.sk__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* the pill at the top of the sheet: hold, then what the stroke became */
.sk__pill {
  position: absolute;
  left: 50%;
  top: 12px;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
}

.sk__pill-in {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 13px 0 10px;
  border-radius: 999px;
  overflow: hidden;
  color: #f2f3f8;
  background: rgba(24, 25, 31, 0.86);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08) inset,
    0 1px 0 rgba(255, 255, 255, 0.12) inset,
    0 6px 16px -6px rgba(10, 12, 30, 0.45),
    0 2px 4px rgba(10, 12, 30, 0.2);
  white-space: nowrap;
}

.sk__pill-icon {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sk__pill-icon g {
  display: none;
}

.sk__pill-icon g.is-on {
  display: inline;
}

.sk__pill.is-shape .sk__pill-icon {
  stroke: #a9b2ff;
}

.sk__pill-text {
  font-size: 12.5px;
  font-weight: 540;
  font-stretch: 106%;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.005em;
}

.sk__pill-bar {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 4px;
  height: 2px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.sk__pill-fill {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #8f9bff, var(--accent));
  transform-origin: 0 50%;
  transform: scaleX(0);
}

/* the pencil: GSAP moves .sk__pencil, the art sits so that the lead is on the point */
.sk__pencil {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
  width: 0;
  height: 0;
  pointer-events: none;
  opacity: 0;
}

.sk__pencil-art {
  position: absolute;
  left: -1px;
  bottom: -1px;
  width: 44px;
  height: 44px;
  transform-origin: 0 100%;
  filter: drop-shadow(4px 5px 3px rgba(40, 32, 20, 0.22)) drop-shadow(10px 14px 10px rgba(40, 32, 20, 0.12));
}

.sk__pencil-art svg {
  width: 100%;
  height: 100%;
  display: block;
}

.sk__p-body {
  fill: #2b2e3a;
}

.sk__p-shine {
  stroke: rgba(255, 255, 255, 0.22);
  stroke-width: 1.4;
  stroke-linecap: round;
  fill: none;
}

.sk__p-band {
  fill: #b9bdc9;
}

.sk__p-cap {
  fill: var(--accent);
}

.sk__p-wood {
  fill: #e6cfa8;
}

.sk__p-lead {
  fill: #23252d;
}

/* the dock */
.sk__dock {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 2px;
}

.sk__tools {
  position: relative;
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.035);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06) inset;
}

.sk__tool-bg {
  position: absolute;
  left: 3px;
  top: 3px;
  width: 36px;
  height: 34px;
  border-radius: 11px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.07));
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.14) inset,
    0 4px 10px -4px rgba(0, 0, 0, 0.6);
}

.sk__tool {
  position: relative;
  width: 36px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: rgba(236, 238, 245, 0.5);
  cursor: pointer;
  transition: color 0.25s;
}

.sk__tool.is-on {
  color: var(--text);
}

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

.sk__snap {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 40px;
  padding: 0 6px 0 12px;
  border: 0;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.035);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06) inset;
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
  font-weight: 540;
  font-stretch: 106%;
  cursor: pointer;
  transition: background-color 0.2s;
}

.sk__switch {
  position: relative;
  width: 40px;
  height: 24px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4) inset;
  transition: background-color 0.3s;
}

.sk__snap[aria-pressed='true'] .sk__switch {
  background: var(--accent);
  box-shadow: 0 1px 2px rgba(0, 0, 20, 0.35) inset, 0 0 14px -2px rgba(75, 91, 255, 0.55);
}

.sk__knob {
  position: absolute;
  left: 2px;
  top: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(180deg, #ffffff, #e4e6ee);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35), 0 0 0 0.5px rgba(0, 0, 0, 0.1);
}

@media (max-width: 380px) {
  .sk__zoom {
    display: none;
  }

  .sk__muted {
    display: none;
  }
}
