/* Live hero demo: a vanilla port of the Notion clone UI, in its dark and light themes. */

.nd {
  --nd-bg: #191919;
  --nd-side: #202020;
  --nd-raised: #252525;
  --nd-text: rgba(255, 255, 255, 0.86);
  --nd-text-2: rgba(255, 255, 255, 0.72);
  --nd-muted: rgba(255, 255, 255, 0.46);
  --nd-faint: rgba(255, 255, 255, 0.28);
  --nd-border: rgba(255, 255, 255, 0.09);
  --nd-hover: rgba(255, 255, 255, 0.055);
  --nd-active: rgba(255, 255, 255, 0.09);
  --nd-accent: #2383e2;
  --nd-code: rgba(255, 255, 255, 0.04);
  --nd-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 12px 32px rgba(0, 0, 0, 0.6);
  --nd-cover-dim: 0.55;
  --nd-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --t-gray: rgba(255, 255, 255, 0.1); --t-gray-fg: rgba(255, 255, 255, 0.8);
  --t-purple: rgba(154, 109, 215, 0.28); --t-purple-fg: #c9a8f2;
  --t-orange: rgba(217, 115, 13, 0.28); --t-orange-fg: #f2b06b;
  --t-blue: rgba(35, 131, 226, 0.28); --t-blue-fg: #8ec2f5;
  --t-pink: rgba(205, 73, 141, 0.28); --t-pink-fg: #f0a2cb;
  --t-red: rgba(224, 62, 62, 0.28); --t-red-fg: #f4a3a3;
  --t-green: rgba(15, 157, 118, 0.28); --t-green-fg: #7fd7b8;

  position: relative;
  aspect-ratio: 1080 / 760;
  overflow: hidden;
  background: var(--nd-bg);
  color: var(--nd-text);
  font: 400 15.5px/1.5 var(--font);
  letter-spacing: 0;
  text-align: left;
  color-scheme: dark;
  transition: background-color 0.2s;

  &[data-theme='light'] {
    --nd-bg: #ffffff;
    --nd-side: #f7f7f5;
    --nd-raised: #ffffff;
    --nd-text: #37352f;
    --nd-text-2: rgba(55, 53, 47, 0.85);
    --nd-muted: rgba(55, 53, 47, 0.55);
    --nd-faint: rgba(55, 53, 47, 0.32);
    --nd-border: rgba(55, 53, 47, 0.1);
    --nd-hover: rgba(55, 53, 47, 0.06);
    --nd-active: rgba(55, 53, 47, 0.09);
    --nd-code: rgba(135, 131, 120, 0.12);
    --nd-shadow: 0 0 0 1px rgba(15, 15, 15, 0.06), 0 6px 20px rgba(15, 15, 15, 0.15);
    --nd-cover-dim: 1;
    --t-gray: rgba(227, 226, 224, 0.7); --t-gray-fg: #32302c;
    --t-purple: #e8deee; --t-purple-fg: #412454;
    --t-orange: #fadec9; --t-orange-fg: #49290e;
    --t-blue: #d3e5ef; --t-blue-fg: #183347;
    --t-pink: #f5e0e9; --t-pink-fg: #4c2337;
    --t-red: #ffe2dd; --t-red-fg: #5d1715;
    --t-green: #dbeddb; --t-green-fg: #1c3829;
    color-scheme: light;
  }

  &.nd--ghost { position: fixed; left: 0; top: 0; z-index: 1000; aspect-ratio: auto; overflow: visible; background: none; pointer-events: none; transform-origin: 0 0; }
  &.is-dragging, &.is-dragging * { cursor: grabbing; }

  svg { flex: none; display: block; }
  button { color: inherit; font: inherit; text-align: inherit; }
  :focus-visible { outline: 2px solid var(--nd-accent); outline-offset: 1px; border-radius: 4px; }
  [contenteditable]:focus-visible { outline: none; }
  kbd { margin-left: auto; color: var(--nd-faint); font: 500 11px/1 var(--font); }
  .nd-muted { color: var(--nd-muted); }

  .nd-app { position: absolute; left: 0; top: 0; display: grid; grid-template-columns: 236px minmax(0, 1fr); width: 1080px; height: 760px; transform-origin: 0 0; outline: none; }
  .nd-icon { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 5px; color: var(--nd-muted); transition: background-color 0.15s, color 0.15s; }
  button.nd-icon:hover { background: var(--nd-hover); color: var(--nd-text); }

  /* ---------- sidebar ---------- */
  .nd-side { display: flex; flex-direction: column; gap: 1px; min-height: 0; padding: 6px 6px 8px; background: var(--nd-side); border-right: 1px solid var(--nd-border); color: var(--nd-text-2); font-size: 14.5px; transition: background-color 0.2s; }
  .nd-ws { display: flex; align-items: center; gap: 8px; height: 36px; margin-bottom: 4px; padding: 0 2px 0 8px; color: var(--nd-text); font-weight: 600; }
  .nd-ws b { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 4px; background: #e9732a; color: #fff; font-size: 11px; }
  .nd-ws > svg { color: var(--nd-muted); }
  .nd-ws .nd-icon { margin-left: auto; }
  .nd-nav { display: flex; align-items: center; gap: 9px; height: 30px; padding: 0 8px; border-radius: 5px; }
  .nd-nav svg { color: var(--nd-muted); }
  button.nd-nav:hover, .nd-row:hover { background: var(--nd-hover); }
  .nd-nav.is-active { background: var(--nd-active); color: var(--nd-text); font-weight: 500; }
  .nd-nav--muted { color: var(--nd-muted); }
  .nd-side__label { margin: 14px 0 2px; padding-left: 8px; color: var(--nd-muted); font-size: 12px; font-weight: 500; }
  .nd-side__end { margin-top: auto; }
  .nd-tree { min-height: 0; overflow: auto; }
  .nd-row { display: flex; align-items: center; gap: 2px; height: 30px; padding-left: calc(4px + var(--depth) * 14px); padding-right: 6px; border-radius: 5px; }
  .nd-row.is-active { background: var(--nd-active); color: var(--nd-text); font-weight: 500; }
  .nd-chev { display: grid; place-items: center; flex: none; width: 20px; height: 20px; border-radius: 4px; color: var(--nd-muted); }
  button.nd-chev:hover { background: var(--nd-hover); }
  .nd-chev svg { transition: transform 0.15s var(--nd-ease); }
  .nd-chev.is-open svg { transform: rotate(90deg); }
  .nd-row__open { display: flex; align-items: center; gap: 7px; min-width: 0; flex: 1; height: 100%; }
  .nd-row__open > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* ---------- top bar ---------- */
  .nd-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
  .nd-top { display: flex; align-items: center; gap: 12px; flex: none; height: 46px; padding: 0 12px; font-size: 14px; }
  .nd-crumbs { display: flex; align-items: center; gap: 2px; min-width: 0; color: var(--nd-text-2); }
  .nd-crumbs > * { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 6px; border-radius: 4px; white-space: nowrap; }
  .nd-crumbs button:hover { background: var(--nd-hover); }
  .nd-crumbs i { padding: 0 1px; color: var(--nd-faint); font-style: normal; }
  .nd-crumbs svg { color: var(--nd-muted); }
  .nd-top__end { display: flex; align-items: center; gap: 4px; margin-left: auto; white-space: nowrap; }
  .nd-top__end > .nd-muted { margin-right: 6px; }
  .nd-top__btn { padding: 3px 8px; border-radius: 4px; }
  .nd-faces { display: flex; margin-right: 10px; }
  .nd-faces b { display: grid; place-items: center; width: 24px; height: 24px; margin-left: -6px; border-radius: 50%; border: 2px solid var(--nd-bg); background: var(--c); color: #fff; font-size: 9.5px; font-weight: 600; }
  .nd-faces b:last-child { position: relative; }
  .nd-faces b:last-child::after { content: ''; position: absolute; right: -2px; bottom: -2px; width: 8px; height: 8px; border-radius: 50%; border: 2px solid var(--nd-bg); background: #22c55e; }

  /* ---------- page ---------- */
  .nd-scroll { position: relative; flex: 1; min-height: 0; overflow: auto; scrollbar-width: thin; }
  .nd-cover { height: 150px; opacity: var(--nd-cover-dim); }
  .nd-cover--lilac { background: linear-gradient(120deg, #d9b8f5, #a9b8fb 55%, #86c2fb); }
  .nd-cover--sunrise { background: linear-gradient(120deg, #b9d3f2, #d8c8f0 50%, #f3c3d6); }
  .nd-cover--mint { background: linear-gradient(120deg, #bfe3cf, #d7ecd9 60%, #e8efe0); }
  .nd-cover-gap { height: 56px; }
  .nd-page { width: 660px; max-width: calc(100% - 96px); margin: 0 auto; padding-bottom: 40px; }
  .nd-page--wide { width: 760px; }
  .nd-page__icon { height: 64px; font-size: 58px; line-height: 64px; }
  .nd-page.has-cover .nd-page__icon { margin-top: -38px; }
  .nd-page__title { margin: 14px 0 10px; color: var(--nd-text); font-size: 38px; font-weight: 700; line-height: 1.2; letter-spacing: -0.01em; outline: none; cursor: text; }
  .nd-page__title.is-empty::before { content: attr(data-placeholder); color: var(--nd-faint); pointer-events: none; }

  .nd-blocks { display: flex; flex-direction: column; }
  .nd-block { display: flex; align-items: flex-start; gap: 6px; padding: 2px 0; }
  .nd-text { flex: 1; min-width: 0; min-height: 1.5em; outline: none; white-space: pre-wrap; overflow-wrap: anywhere; cursor: text; caret-color: var(--nd-text); }
  .nd-text.is-empty::before { content: attr(data-placeholder); color: var(--nd-faint); pointer-events: none; }
  .nd-block--text .nd-text.is-empty:not(:focus)::before { content: none; }
  .nd-block--h1 { margin-top: 18px; }
  .nd-block--h1 .nd-text { font-size: 28px; font-weight: 700; line-height: 1.3; }
  .nd-block--h2 { margin-top: 14px; }
  .nd-block--h2 .nd-text { font-size: 22px; font-weight: 650; line-height: 1.3; }
  .nd-block--h3 { margin-top: 10px; }
  .nd-block--h3 .nd-text { font-size: 18px; font-weight: 650; }
  .nd-marker { flex: none; min-width: 22px; padding-right: 2px; text-align: center; }
  .nd-block--bullet .nd-marker { font-size: 19px; line-height: 23px; }
  .nd-check { display: grid; place-items: center; flex: none; width: 17px; height: 17px; margin: 3.5px 4px 0 3px; border: 1.5px solid var(--nd-muted); border-radius: 3px; color: transparent; transition: background-color 0.12s, border-color 0.12s; }
  .nd-check:hover { background: var(--nd-hover); }
  .is-checked > .nd-check { background: var(--nd-accent); border-color: var(--nd-accent); color: #fff; }
  .is-checked > .nd-text { color: var(--nd-muted); text-decoration: line-through; text-decoration-color: var(--nd-faint); }
  .nd-block--quote .nd-text { padding: 0 0 0 14px; border-left: 3px solid currentColor; font-size: 15.5px; }
  .nd-block--code { margin: 4px 0; }
  .nd-block--code .nd-text { padding: 22px 24px; border-radius: 4px; background: var(--nd-code); font: 400 14px/1.6 var(--mono); }
  .nd-block--divider { padding: 10px 0; }
  .nd-block--divider hr { width: 100%; height: 1px; margin: 0; border: 0; background: var(--nd-border); }
  .nd-tail { height: 140px; cursor: text; }

  /* ---------- slash menu ---------- */
  .nd-slash { position: absolute; z-index: 5; width: 290px; max-height: 300px; overflow: auto; padding: 6px; border-radius: 8px; background: var(--nd-raised); box-shadow: var(--nd-shadow); scrollbar-width: thin; }
  .nd-slash__group, .nd-search__group { padding: 6px 8px 4px; color: var(--nd-muted); font-size: 11.5px; font-weight: 500; }
  .nd-slash__item { display: flex; align-items: center; gap: 10px; padding: 4px 6px; border-radius: 5px; cursor: pointer; }
  .nd-slash__item.is-active { background: var(--nd-hover); }
  .nd-slash__item b { display: block; font-size: 13.5px; font-weight: 500; }
  .nd-slash__item em { display: block; color: var(--nd-muted); font-size: 11.5px; font-style: normal; }
  .nd-slash__glyph { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 5px; border: 1px solid var(--nd-border); background: var(--nd-bg); color: var(--nd-text-2); font-size: 14px; font-weight: 600; }

  /* ---------- home ---------- */
  .nd-home { width: 720px; margin: 0 auto; padding-top: 72px; }
  .nd-home h1 { color: var(--nd-text); font-size: 28px; font-weight: 700; text-align: center; }
  .nd-home__label { display: flex; align-items: center; gap: 6px; margin: 44px 0 10px; color: var(--nd-muted); font-size: 12.5px; font-weight: 500; }
  .nd-home__grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
  .nd-home__card { display: flex; flex-direction: column; height: 118px; padding: 14px; border-radius: 10px; border: 1px solid var(--nd-border); background: var(--nd-raised); transition: background-color 0.15s, transform 0.15s var(--nd-ease); }
  .nd-home__card:hover { background: var(--nd-hover); transform: translateY(-1px); }
  .nd-home__icon { font-size: 28px; line-height: 1; }
  .nd-home__card b { margin-top: auto; font-size: 13.5px; font-weight: 500; }
  .nd-home__card em { color: var(--nd-muted); font-size: 11.5px; font-style: normal; }

  /* ---------- database ---------- */
  .nd-dbbar { display: flex; align-items: center; gap: 4px; padding-bottom: 6px; border-bottom: 1px solid var(--nd-border); color: var(--nd-muted); font-size: 13px; }
  .nd-dbbar [role='tablist'] { display: flex; gap: 2px; }
  .nd-dbbar > span { display: inline-flex; align-items: center; gap: 5px; padding: 3px 6px; }
  .nd-dbbar__end { margin-left: auto; }
  .nd-view { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 8px; border-radius: 5px; color: var(--nd-muted); }
  .nd-view:hover { background: var(--nd-hover); }
  .nd-view.is-active { color: var(--nd-text); font-weight: 500; box-shadow: inset 0 -2px 0 var(--nd-text); border-radius: 5px 5px 0 0; }
  .nd-table { font-size: 14.5px; }
  .nd-table__row { display: grid; grid-template-columns: minmax(0, 1fr) 200px 150px; min-height: 36px; border-bottom: 1px solid var(--nd-border); }
  .nd-table__row > * { display: flex; align-items: center; gap: 6px; min-width: 0; padding: 0 8px; }
  .nd-table__row > * + * { border-left: 1px solid var(--nd-border); }
  .nd-table__head { min-height: 34px; color: var(--nd-muted); font-size: 13px; }
  .nd-table__name { font-weight: 500; }
  .nd-table__name svg { color: var(--nd-muted); }
  .nd-status-btn { display: flex; padding: 2px; border-radius: 5px; }
  .nd-status-btn:hover { background: var(--nd-hover); }
  .nd-tag, .nd-status { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 7px; border-radius: 4px; font-size: 12px; white-space: nowrap; }
  .nd-tag--gray, .nd-status--not_started { background: var(--t-gray); color: var(--t-gray-fg); }
  .nd-tag--purple { background: var(--t-purple); color: var(--t-purple-fg); }
  .nd-tag--orange { background: var(--t-orange); color: var(--t-orange-fg); }
  .nd-tag--blue, .nd-status--in_progress { background: var(--t-blue); color: var(--t-blue-fg); }
  .nd-tag--pink { background: var(--t-pink); color: var(--t-pink-fg); }
  .nd-tag--red { background: var(--t-red); color: var(--t-red-fg); }
  .nd-status--done { background: var(--t-green); color: var(--t-green-fg); }
  .nd-status { border-radius: 10px; }
  .nd-status i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: 0.8; }

  .nd-board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding-top: 12px; }
  .nd-col { min-height: 300px; padding: 4px; border-radius: 8px; transition: background-color 0.15s; }
  .nd-col.is-over { background: var(--nd-hover); }
  .nd-col__head { display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 4px; }
  .nd-col__head em { color: var(--nd-muted); font-size: 12.5px; font-style: normal; }
  .nd-col__body { display: flex; flex-direction: column; gap: 6px; min-height: 60px; }
  .nd-card { display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 6px; background: var(--nd-raised); box-shadow: var(--nd-shadow); cursor: grab; touch-action: none; user-select: none; }
  .nd-card b { font-size: 14.5px; font-weight: 500; }
  .nd-card > span { display: flex; flex-wrap: wrap; gap: 4px; }
  .nd-card.is-dragging { opacity: 0.35; }
  &.nd--ghost .nd-card { transform: rotate(2deg); }
  .nd-drop { height: 2px; margin: -4px 2px; border-radius: 1px; background: var(--nd-accent); }

  /* ---------- search ---------- */
  .nd-layer { position: absolute; inset: 0; pointer-events: none; }
  .nd-layer > * { pointer-events: auto; }
  .nd-backdrop { position: absolute; inset: 0; background: rgba(15, 15, 15, 0.45); }
  .nd-search { position: absolute; left: 50%; top: 90px; width: 560px; transform: translateX(-50%); overflow: hidden; border-radius: 10px; background: var(--nd-raised); box-shadow: var(--nd-shadow); }
  .nd-search__input { display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 16px; border-bottom: 1px solid var(--nd-border); color: var(--nd-muted); }
  .nd-search__input input { flex: 1; min-width: 0; border: 0; background: none; color: var(--nd-text); font: inherit; font-size: 15px; outline: none; }
  .nd-search__input input::placeholder { color: var(--nd-faint); }
  .nd-search__list { max-height: 320px; overflow: auto; padding: 0 6px 6px; }
  .nd-result { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border-radius: 5px; cursor: pointer; }
  .nd-result.is-active { background: var(--nd-hover); }
  .nd-result em { margin-left: auto; color: var(--nd-muted); font-size: 12px; font-style: normal; }
  .nd-search__empty { padding: 14px 10px; color: var(--nd-muted); }

  @media (prefers-reduced-motion: no-preference) {
    .nd-slash { animation: nd-pop 120ms var(--nd-ease); }
    .nd-backdrop { animation: nd-fade 150ms ease-out; }
    .nd-search { animation: nd-drop 180ms var(--nd-ease); }
  }
  @keyframes nd-fade { from { opacity: 0; } }
  @keyframes nd-pop { from { opacity: 0; transform: translateY(-4px); } }
  @keyframes nd-drop { from { opacity: 0; transform: translate(-50%, -8px); } }
}

@media (width <= 760px) {
  .nd { display: none; }
}
