/* web/app/app.css: styles only this app needs. Generic tokens only, as the
   kit's lint asks of fragments. A part a prototype could also use belongs in
   ui-kit instead. */

body {
  margin: 0;
  background: var(--color-config-screen);
  color: var(--color-ui-content);
  font-family: var(--font-inter);
}

/* ---- shared helpers ------------------------------------------------------ */

.raketa-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-16);
}

.raketa-stack-tight {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
}

.raketa-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-8);
}

.raketa-grow {
  flex: 1;
  min-width: var(--size-192);
}

.raketa-page {
  max-width: var(--size-768);
  margin: 0 auto;
  width: 100%;
}

.raketa-page-title {
  margin: 0;
}

.raketa-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.raketa-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
}

.raketa-code {
  display: block;
  padding: var(--space-8);
  border-radius: var(--radius-6);
  background: var(--color-ui-container);
  font-family: var(--font-mono);
  font-size: var(--text-12);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.raketa-spec {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.raketa-section-head {
  display: flex;
  align-items: center;
  gap: var(--space-8);
}

.raketa-section-head > h2 {
  margin: 0;
  flex: 1;
}

.raketa-cell-actions {
  white-space: nowrap;
  text-align: right;
}

/* A confirm dialog sits in its trigger's cell, but must not inherit the cell's text layout. */
.raketa-cell-actions as-alert-dialog > dialog {
  white-space: normal;
  text-align: start;
}

tr[data-muted],
.as-item[data-muted] {
  opacity: 0.6;
}

/* ---- sign in and the server-only pages (Continue, password, errors) ------- */

/* The kit's layout is min-height: 100vh plus padding without border-box, so the
   page scrolled by twice the padding. */
.as-layout-centered {
  box-sizing: border-box;
  background: var(--color-config-screen);
}

/* One centred card: the mark, a heading, then the form. Sizes from the
   raketa-ext-auth frame. */
.raketa-auth-card {
  align-items: center;
  gap: var(--space-16);
  width: 100%;
  max-width: calc(var(--size-384) + var(--space-16));
  margin: 0 auto;
  padding: var(--space-48) var(--space-32) var(--space-32);
  border-radius: calc(2 * var(--radius-12));
  text-align: center;
}

.raketa-auth-card > [data-slot="header"],
.raketa-auth-card > [data-slot="content"] {
  box-sizing: border-box;
  width: 100%;
  padding: 0;
}

.raketa-auth-card > [data-slot="header"] > [data-slot="title"] {
  margin: 0;
  font-family: var(--type-heading-family);
  font-size: var(--type-heading-size);
  line-height: var(--type-heading-line);
  font-weight: var(--type-heading-weight);
}

.raketa-auth-card > [data-slot="content"] {
  margin-top: var(--space-8);
  text-align: left;
}

.raketa-auth-card form {
  gap: var(--space-20);
}

.raketa-auth-card as-input-otp {
  align-self: center;
}

.raketa-auth-card .as-button {
  width: 100%;
}

.raketa-plain-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-12);
}

/* ---- app layout: as-sidebar, a header over a scrolling main -------------- */

/* A 320px sidebar on the screen colour, as in the raketa-int frames. */
.raketa-app {
  --sidebar-width: var(--size-320);
  height: 100vh;
}

/* The header runs edge to edge, so the main area has no padding of its own. */
.raketa-app > [data-slot="inset"] {
  min-height: 0;
  padding: 0;
}

/* A column, so a folder page's drop zone can fill the height. position:
   relative holds .raketa-sr-only labels, which are absolutely positioned;
   without it they escape main's scrolling and stretch the document. */
.raketa-app main[data-slot="main"] {
  position: relative;
  display: flex;
  flex-direction: column;
}

/* People fills the height too, so its empty state sits in the middle. */
.raketa-app main[data-slot="main"] > raketa-people,
.raketa-people {
  display: flex;
  flex-direction: column;
  flex: 1 0 auto;
}

/* The sheet and invite dialog open in the top layer; closed, they must not add stack gaps. */
.raketa-people > :is(as-sheet, as-dialog) {
  position: absolute;
}

.raketa-app main[data-slot="main"] > raketa-library {
  display: flex;
  flex-direction: column;
  flex: 1 0 auto;
  gap: var(--space-16);
}

.raketa-mark {
  display: block;
  flex: none;
  border-radius: var(--radius-4);
}

/* The switcher is the sidebar header, so it carries no box of its own. */
.raketa-switcher {
  cursor: default;
}

button.raketa-switcher {
  cursor: pointer;
}
.raketa-menu {
  min-width: var(--size-256);
}

/* In a menu with avatars, an icon gets the avatar's width so every label starts
   at the same edge. */
.raketa-menu:has(as-avatar) [data-slot="item"] > .as-icon {
  margin-inline: calc((var(--size-control-xs) - var(--icon-md-width)) / 2);
}

.raketa-menu-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.raketa-crumbs {
  min-width: 0;
}

.raketa-crumbs [data-slot="list"] {
  flex-wrap: nowrap;
}

.raketa-crumbs [data-slot="item"] {
  min-width: 0;
}

.raketa-crumbs [data-slot="item"] > * {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- pages: header, toolbar, cards, drop zones ----------------------------- */

.raketa-page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-12);
  min-height: var(--size-40);
}

.raketa-page-head > .raketa-page-title {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.raketa-page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-8);
}

.raketa-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: var(--space-8);
}

.raketa-status {
  align-items: center;
}

/* Supportive text; inside a label it also drops to body weight. */
.raketa-muted {
  color: var(--color-ui-supportive);
  font-weight: var(--type-body-weight);
}

.raketa-fill {
  flex: 1 0 auto;
  justify-content: center;
}

/* A 40px square holding an icon: folder cards, page headers, version rows. */
.raketa-tile {
  display: grid;
  place-items: center;
  flex: none;
  box-sizing: border-box;
  width: var(--size-40);
  height: var(--size-40);
  border: var(--border-width) solid var(--color-ui-line);
  border-radius: var(--radius-control);
  background: var(--color-ui-surface);
}

.raketa-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-16);
}

/* Folder and prototype cards: kit items whose link covers the row, at the
   frames' 64px height and panel radius; the menu shows on hover or focus. */
.raketa-card {
  --item-radius: var(--radius-panel);
  box-sizing: border-box;
  height: var(--size-64);
}

/* The count is a caption, as in the frames. */
.raketa-card [data-slot="description"] {
  font-size: var(--type-caption-size);
  line-height: var(--type-caption-line);
}

/* A label over a caption, each cut to one line. */
.raketa-card-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.raketa-card-text > * {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.raketa-card-menu {
  opacity: 0;
}

.raketa-card:hover .raketa-card-menu,
.raketa-card:focus-within .raketa-card-menu,
.raketa-card-menu[aria-expanded="true"] {
  opacity: 1;
}

@media (hover: none) {
  .raketa-card-menu {
    opacity: 1;
  }
}

/* A card that takes a dropped zip: the kit's ghost zone, pulled out by its
   transparent border so the card keeps its 64px cell. While a file is over
   it, the card clears to show the zone's dashed state. */
.raketa-card-zone {
  margin: calc(-1 * var(--border-width));
}

.raketa-card-zone[data-dragging] > .raketa-card {
  border-color: transparent;
  background: transparent;
}

/* A folder page: one ghost zone over the whole content, so a zip dropped
   anywhere lands in this folder; its dashed edge sits just outside. */
.raketa-zone {
  display: flex;
  flex: 1 0 auto;
  flex-direction: column;
  gap: var(--space-16);
}

/* Outranks the kit's zone, which centres its children, and its ghost
   variant, which is display: block. */
as-dropzone.raketa-zone {
  display: flex;
  align-items: stretch;
  justify-content: flex-start;
  margin: calc(-1 * var(--space-12));
  padding: calc(var(--space-12) - var(--border-width));
}

/* The empty folder and New version: the kit's dashed zone (04-int-proj-b). */
.raketa-drop {
  flex: 1 0 auto;
  min-height: var(--size-320);
}

.raketa-drop > .as-title {
  color: var(--color-ui-content);
}

.raketa-folder-list .raketa-list-name {
  display: inline-flex;
  align-items: center;
  gap: var(--space-8);
  color: inherit;
  font-weight: var(--type-label-weight);
  text-decoration: none;
}

.raketa-folder-list .raketa-list-name:hover {
  text-decoration: underline;
}

/* ---- prototype ------------------------------------------------------------ */

.raketa-prototype-body {
  max-width: var(--size-768);
}

/* The "N versions" list (13-versions-list): 56px rows, newest first. */
.raketa-versions {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin: 0;
  padding: 0;
  list-style: none;
}

.raketa-version {
  display: flex;
  align-items: center;
  gap: var(--space-12);
  box-sizing: border-box;
  min-height: var(--size-56);
  padding: var(--space-8);
  border-radius: var(--radius-panel);
  color: inherit;
  text-decoration: none;
}

.raketa-version:hover {
  background: var(--color-interactive-neutral-hover);
}

.raketa-version:focus-visible {
  outline: var(--border-width) solid var(--color-interactive-primary-focus);
}

.raketa-version-meta {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  min-width: 0;
  margin-left: auto;
}

.raketa-notes {
  max-width: var(--size-320);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.raketa-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(var(--size-160), 1fr));
  gap: var(--space-12);
}

/* The share-link table needs more room than the kit dialog's default width. */
.raketa-share {
  --dialog-content-max-width: calc(var(--size-768) + var(--size-128));
}

.raketa-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(var(--size-256), 1fr));
  gap: var(--space-16);
}

.raketa-spec-card > summary {
  cursor: pointer;
  list-style: none;
}

/* Comment cards read best at the Feedback list frame's width. */
.raketa-inbox-list {
  max-width: var(--size-640);
}

.raketa-inbox-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-4);
  min-width: 0;
  color: var(--color-ui-supportive);
  text-decoration: none;
}

.raketa-inbox-link:hover {
  color: var(--color-ui-content);
  text-decoration: underline;
}

/* ---- narrower windows ----------------------------------------------------- */

@media (max-width: 1023px) {
  .raketa-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ---- people: table rows open the person's sheet ------------------------- */

.raketa-people-table [data-slot="body"] [data-slot="row"] {
  cursor: pointer;
}

.raketa-person {
  display: flex;
  align-items: center;
  gap: var(--space-12);
  min-width: 0;
}

.raketa-person-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* The row is the target; this button gives it a keyboard stop and a name. */
.raketa-row-button {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  text-align: start;
  cursor: pointer;
}

.raketa-row-button:focus-visible {
  outline: var(--border-width) solid var(--color-interactive-primary-focus);
  outline-offset: var(--space-2);
  border-radius: var(--radius-4);
}

/* The access table needs room for folder paths beside their level, and the
   labelled sections need more air than the kit's field-to-field gap. */
.raketa-person-sheet {
  --sheet-content-width: var(--size-512);
  --sheet-body-gap: var(--space-24);
}

/* The kit drops heading margins only for the body's own children; these sit in sections. */
.raketa-person-sheet section > :is(h3, p) {
  margin: 0;
}

/* Remove sits apart from Cancel and Save, at the footer's start. */
.raketa-footer-start {
  margin-inline-end: auto;
}

/* Levels line up in one column, whatever the folder path's length. */
.raketa-folder-levels [data-slot="trailing"] .as-native-select-wrapper {
  width: var(--size-160);
}

/* Phones: the kit sidebar is off-canvas; the breadcrumb keeps its last two
   crumbs, grids drop to one column, header actions wrap under the title. */
@media (max-width: 767px) {
  .raketa-crumbs [data-slot="list"] > li:not(:nth-last-child(-n + 3)) {
    display: none;
  }

  .raketa-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .raketa-page-actions {
    flex-basis: 100%;
  }

  .raketa-folder-list .raketa-list-actions {
    display: none;
  }

  .raketa-version {
    flex-wrap: wrap;
  }

  .raketa-version-meta {
    flex-basis: 100%;
    margin-left: calc(var(--size-40) + var(--space-12));
  }
}

/* ---- comment card (web/app/lib/comment-card.js) ---------------------------- */

.raketa-comment-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
  padding: var(--space-12);
  border: var(--border-width) solid var(--color-ui-line);
  border-radius: var(--radius-panel);
  background: var(--color-ui-elevated);
}

.raketa-comment-card[data-selected] {
  border-color: var(--raketa-pin-surface);
}

.raketa-comment-card[data-resolved] {
  opacity: 0.7;
}

.raketa-comment-card[data-nested] {
  padding: 0;
  border: 0;
  background: none;
}

.raketa-comment-card-head {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  min-width: 0;
}

.raketa-comment-card-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.raketa-comment-card-time {
  margin-left: auto;
  flex-shrink: 0;
}

.raketa-comment-text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Mark as resolved and the own-comment menu, after the time, as in Figma. */
.raketa-comment-card-actions {
  display: inline-flex;
  flex-shrink: 0;
  margin: calc(var(--space-4) * -1) calc(var(--space-4) * -1) calc(var(--space-4) * -1) 0;
}

/* A resolved comment's check is filled, as in Figma. Lucide's check is an
   outline, so the circle takes the text colour and the check the surface
   colour behind it. */
.raketa-resolve[data-resolved] .as-icon {
  fill: currentColor;
  stroke: var(--color-ui-elevated);
}

/* A card that opens its thread on the prototype. */
.raketa-comment-card[data-openable] {
  cursor: pointer;
}

.raketa-comment-card[data-openable]:hover {
  border-color: var(--color-interactive-neutral-line-hover);
}

.raketa-comment-card[data-openable]:focus-visible {
  outline: var(--border-2) solid var(--color-interactive-primary-focus);
  outline-offset: calc(var(--border-width) * -1);
}

.raketa-reply-count {
  display: inline-flex;
  align-items: center;
  gap: var(--space-4);
}

/* The element the pin is on, as in the design: outline chip, pointer icon. */
.raketa-target-chip {
  align-self: flex-start;
  max-width: 100%;
}

.raketa-target-chip > [data-slot="label"] {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
