/* This file is for your main application CSS. */

/*
 * The Plot design tokens.
 *
 * A quiet, neutral palette with a single indigo accent, hairline borders and
 * restrained radii. The tokens also restate the theme the daisyUI components
 * draw from, so this stylesheet and every component on the page speak with
 * one voice. This file loads after the component styles it refines.
 */
:root {
  --plot-surface: #ffffff;
  --plot-surface-muted: #fafbfc;
  --plot-surface-sunken: #f1f3f5;
  --plot-hairline: #e6e8eb;
  --plot-hairline-strong: #d3d7dd;
  --plot-ink: #111827;
  --plot-ink-muted: #6b7280;
  --plot-ink-faint: #9ca3af;
  --plot-accent: #4f46e5;
  --plot-accent-soft: #eef0ff;
  --plot-accent-ink: #3730a3;
  --plot-danger: #b91c1c;

  --plot-radius-sm: 0.375rem;
  --plot-radius: 0.5rem;
  --plot-radius-lg: 0.75rem;

  --plot-shadow: 0 1px 2px rgb(17 24 39 / 5%);
  --plot-ring: 0 0 0 3px rgb(79 70 229 / 15%);

  /* The width of an ordinary page: the column the main screen is centred in,
   * and the width of the card a screen that asks one thing of the visitor
   * presents it in. */
  --plot-page-width: 56rem;
  --plot-card-width: 24rem;

  /* The daisyUI theme the components draw from. */
  --color-base-100: var(--plot-surface);
  --color-base-200: var(--plot-surface-sunken);
  --color-base-300: var(--plot-hairline);
  --color-base-content: var(--plot-ink);
  --color-primary: var(--plot-accent);
  --color-primary-content: #ffffff;
  --color-neutral: #1f2937;
  --color-neutral-content: #ffffff;
  --color-error: var(--plot-danger);
  --radius-box: var(--plot-radius-lg);
  --radius-field: var(--plot-radius);
  --radius-selector: var(--plot-radius-sm);
  --depth: 0;
  --noise: 0;
}

body {
  background-color: var(--plot-surface-muted);
  color: var(--plot-ink);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

:focus-visible {
  outline: 2px solid color-mix(in oklab, var(--plot-accent) 60%, white);
  outline-offset: 2px;
}

/* Headings are quiet and tight: the content carries the hierarchy. */
.app-shell-main h1 {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.011em;
}

.app-shell-main p {
  color: var(--plot-ink-muted);
}

/*
 * The application shell: a slim sticky top bar, the main screen and the
 * footer. The shell fills the viewport, and the footer sits at its bottom.
 */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
}

.app-shell > header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 3.5rem;
  padding: 0 clamp(1rem, 3vw, 2rem);
  border-bottom: 1px solid var(--plot-hairline);
  background-color: color-mix(in oklab, var(--plot-surface) 90%, transparent);
  backdrop-filter: blur(10px);
}

.app-shell-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: inherit;
  text-decoration: none;
}

.app-shell-brand span {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.011em;
}

/* The name of the model the screen is about, after the Plot logo. */
.app-shell-context {
  font-size: 1rem;
  font-weight: 500;
  color: var(--plot-ink-muted);
}

.app-shell-main {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  width: 100%;
  /* The main screen of an ordinary page is centred in the page width, so a
   * page never stretches its content across the whole workspace. */
  max-width: var(--plot-page-width);
  margin-inline: auto;
  padding: 1.5rem clamp(1rem, 3vw, 2rem) 2.5rem;
}

/* A screen that fills the workspace, like the Model Management screen, keeps
 * the full width of the shell. */
.app-shell-main-full {
  max-width: none;
}

/* A screen that asks one thing of the visitor, like signing in or naming a
 * model, is centred in the shell, both ways, with the footer below it. */
.app-shell-main-centered {
  align-items: center;
  justify-content: center;
  max-width: none;
  padding-bottom: 1.5rem;
}

/*
 * The Card: one quiet surface that holds a title, the fields it asks for and
 * the action that commits them. It is the whole of a centred screen, so it
 * leads with its title and spans its action, the way a considered form does.
 */
.app-card {
  width: 100%;
  max-width: var(--plot-card-width);
  padding: 1.75rem;
  border: 1px solid var(--plot-hairline);
  border-radius: var(--plot-radius-lg);
  background-color: var(--plot-surface);
  box-shadow: var(--plot-shadow);
}

.app-card header {
  text-align: center;
}

.app-card .btn {
  width: 100%;
}

.app-card form > .btn {
  margin-top: 0.75rem;
}

.app-card .auth-hint {
  text-align: center;
}

.app-shell > footer {
  margin-top: auto;
  width: 100%;
  padding: 1rem clamp(1rem, 3vw, 2rem);
  border-top: 1px solid var(--plot-hairline);
}

.app-shell > footer .link {
  font-size: 0.8125rem;
  color: var(--plot-ink-faint);
  text-decoration: none;
}

.app-shell > footer .link:hover {
  color: var(--plot-ink);
}

/*
 * The Model Navigation: the sections of a model, as a segmented control at
 * the top of the Model screen.
 */
.model-navigation {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.125rem;
  width: fit-content;
  margin-bottom: 1.5rem;
  padding: 0.25rem;
  border: 1px solid var(--plot-hairline);
  border-radius: var(--plot-radius-lg);
  background-color: var(--plot-surface);
}

.model-navigation a {
  padding: 0.375rem 0.875rem;
  border-radius: var(--plot-radius);
  color: var(--plot-ink-muted);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition:
    background-color 120ms ease,
    color 120ms ease;
}

.model-navigation a:hover {
  background-color: var(--plot-surface-sunken);
  color: var(--plot-ink);
}

.model-navigation a[aria-current="page"] {
  background-color: var(--plot-accent-soft);
  color: var(--plot-accent-ink);
  font-weight: 600;
}

/*
 * The Model Layout: the Sidebar Layout of a section, or the fixed menu of the
 * Model Settings interface, beside the body of the interface.
 */
.model-management-layout {
  display: flex;
  flex: 1 1 auto;
  align-items: stretch;
  gap: 2rem;
  min-height: 0;
}

.model-management-body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 1.25rem;
  min-width: 0;
}

/*
 * The Sidebar Layout. The Collapse toggle Button collapses it horizontally:
 * the sidebar keeps its rail and hides its folders and views.
 */
.sidebar {
  flex: 0 0 15rem;
  padding-right: 1.25rem;
  border-right: 1px solid var(--plot-hairline);
  overflow: hidden;
  transition: flex-basis 150ms ease;
}

.sidebar-collapsed {
  flex-basis: 3.25rem;
  padding-right: 0;
}

.sidebar-collapsed .sidebar-title,
.sidebar-collapsed .sidebar-tree,
.sidebar-collapsed .sidebar-empty {
  display: none;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.sidebar-title {
  color: var(--plot-ink-faint);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.sidebar-toggle-icon {
  transition: transform 150ms ease;
}

.sidebar-collapsed .sidebar-toggle-icon {
  transform: rotate(180deg);
}

/*
 * The Folder Layout and the View & recursive Subviews it contains.
 */
.sidebar-tree,
.sidebar-views {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
}

.sidebar-views {
  margin-top: 0;
  padding-left: 0.75rem;
}

/*
 * The Folder Layout's header: the folder label with the Add View Button that
 * inserts a view on top of the folder.
 */
.sidebar-folder-header {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.sidebar-folder-header .sidebar-item {
  flex: 1 1 auto;
  min-width: 0;
}

.sidebar-add-view {
  flex: none;
}

.sidebar-label {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  width: 100%;
  padding: 0.4rem 0.5rem;
  border: 0;
  border-radius: var(--plot-radius);
  background: none;
  color: var(--plot-ink);
  font-size: 0.875rem;
  text-align: left;
  cursor: pointer;
  transition: background-color 120ms ease;
}

.sidebar-label:hover {
  background-color: var(--plot-surface-sunken);
}

.sidebar-caret {
  color: var(--plot-ink-faint);
  transition: transform 150ms ease;
}

.sidebar-label[aria-expanded="true"] .sidebar-caret {
  transform: rotate(90deg);
}

.sidebar-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-empty {
  margin-top: 0.75rem;
  color: var(--plot-ink-faint);
  font-size: 0.8125rem;
}

.sidebar-edit {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/*
 * The Model Settings Menu: the fixed menu of the settings a model groups.
 */
.settings-menu {
  flex: 0 0 15rem;
  padding-right: 1.25rem;
  border-right: 1px solid var(--plot-hairline);
}

.settings-menu-title {
  color: var(--plot-ink-faint);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.settings-menu-list {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  margin-top: 0.75rem;
}

.settings-menu-item {
  display: block;
  padding: 0.4rem 0.5rem;
  border-radius: var(--plot-radius);
  color: var(--plot-ink-muted);
  font-size: 0.875rem;
  text-decoration: none;
  transition: background-color 120ms ease, color 120ms ease;
}

.settings-menu-item:hover {
  background-color: var(--plot-surface-sunken);
  color: var(--plot-ink);
}

.settings-menu-item[aria-current="page"] {
  background-color: var(--plot-accent-soft);
  color: var(--plot-accent-ink);
  font-weight: 600;
}

/*
 * The Canvas Layout of the Modelling UI: the canvas fills the body of the
 * interface it is in, framed like any other surface.
 */
.modelling-ui {
  flex: 1 1 auto;
  min-height: 24rem;
  border: 1px solid var(--plot-hairline);
  border-radius: var(--plot-radius-lg);
  background-color: var(--plot-surface);
  overflow: hidden;
}

/*
 * On narrow screens a sidebar stacks above the body of its interface instead
 * of squeezing it, and the horizontal collapse only applies side by side.
 */
@media (max-width: 768px) {
  .model-management-layout {
    flex-direction: column;
  }

  .sidebar,
  .sidebar-collapsed,
  .settings-menu {
    flex-basis: auto;
    width: 100%;
    padding-right: 0;
    border-right: 0;
    border-bottom: 1px solid var(--plot-hairline);
    padding-bottom: 1rem;
  }
}

/*
 * The daisyUI components, quietened to the same voice as the rest: hairline
 * borders, flat surfaces, one accent.
 */
.btn {
  border-radius: var(--plot-radius);
  font-weight: 500;
  box-shadow: var(--plot-shadow);
}

.btn-ghost,
.btn-primary {
  box-shadow: none;
}

.btn-sm {
  font-size: 0.8125rem;
}

.input,
.select,
.textarea {
  border-color: var(--plot-hairline-strong);
  border-radius: var(--plot-radius);
  background-color: var(--plot-surface);
}

.input:focus,
.input:focus-within,
.select:focus,
.textarea:focus {
  border-color: var(--plot-accent);
  box-shadow: var(--plot-ring);
  outline: none;
}

.label {
  color: var(--plot-ink-muted);
  font-size: 0.8125rem;
  font-weight: 500;
}

/*
 * The providers of the Sign In and Sign Up interfaces, as quiet, bordered
 * buttons, so the accent stays with the primary action of a screen.
 */
.auth-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 22rem;
  margin-top: 0.5rem;
}

.provider-button {
  justify-content: center;
  border: 1px solid var(--plot-hairline-strong);
  border-radius: var(--plot-radius);
  background-color: var(--plot-surface);
  color: var(--plot-ink);
  font-weight: 500;
  box-shadow: var(--plot-shadow);
}

.provider-button:hover {
  border-color: var(--plot-ink-faint);
  background-color: var(--plot-surface-muted);
}

.auth-hint {
  margin-top: 1rem;
  font-size: 0.875rem;
}

.list {
  padding: 0;
}

.list-row {
  border-bottom: 1px solid var(--plot-hairline);
}

.list-row:last-child {
  border-bottom: 0;
}

.alert {
  border-radius: var(--plot-radius-lg);
  border-color: var(--plot-hairline);
  box-shadow: var(--plot-shadow);
}

/* The status and empty states of a screen. */
.app-shell-main [role="status"],
.app-shell-main [role="alert"] {
  color: var(--plot-ink-muted);
}

/*
 * The Identity of the Top Level Navigation: the Sign In link a visitor sees,
 * and the Account Menu an active user sees. The Account Menu is the Account
 * Management interface, which the Pulldown technology presents as a menu.
 */
.identity-menu {
  position: relative;
}

.identity-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  height: 2.25rem;
  padding: 0 0.625rem;
  border-radius: var(--plot-radius);
  color: var(--plot-ink);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  list-style: none;
  transition: background-color 120ms ease;
}

.identity-trigger::-webkit-details-marker {
  display: none;
}

.identity-trigger:hover {
  background-color: var(--plot-surface-sunken);
}

.identity-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 9999px;
  background-color: var(--plot-accent-soft);
  color: var(--plot-accent-ink);
  font-size: 0.75rem;
  font-weight: 600;
}

.identity-caret {
  width: 0;
  height: 0;
  border-left: 0.25rem solid transparent;
  border-right: 0.25rem solid transparent;
  border-top: 0.3rem solid var(--plot-ink-faint);
  transition: transform 150ms ease;
}

.identity-menu[open] .identity-caret {
  transform: rotate(180deg);
}

.identity-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  z-index: 30;
  width: 16rem;
  padding: 0.5rem;
  border: 1px solid var(--plot-hairline);
  border-radius: var(--plot-radius-lg);
  background-color: var(--plot-surface);
  box-shadow: 0 8px 24px rgb(17 24 39 / 10%);
}

.identity-section + .identity-section {
  margin-top: 0.25rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--plot-hairline);
}

/* Whatever leads the menu leads it: a separator over nothing reads as a
 * section that failed to render. */
.identity-dropdown > :first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.identity-section-title {
  padding: 0.25rem 0.5rem;
  color: var(--plot-ink-faint);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.identity-list {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.identity-item {
  display: block;
  padding: 0.4rem 0.5rem;
  border-radius: var(--plot-radius);
  color: var(--plot-ink-muted);
  font-size: 0.875rem;
  text-decoration: none;
  transition: background-color 120ms ease, color 120ms ease;
}

.identity-item:hover {
  background-color: var(--plot-surface-sunken);
  color: var(--plot-ink);
}

.identity-item[aria-current="page"] {
  background-color: var(--plot-accent-soft);
  color: var(--plot-accent-ink);
  font-weight: 600;
}

.identity-collaborator {
  display: flex;
  flex-direction: column;
  padding: 0.4rem 0.5rem;
}

.identity-collaborator-name {
  color: var(--plot-ink);
  font-size: 0.875rem;
}

.identity-collaborator-email {
  color: var(--plot-ink-faint);
  font-size: 0.75rem;
}

.identity-footer {
  margin-top: 0.25rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--plot-hairline);
}

.identity-sign-out {
  display: block;
  padding: 0.4rem 0.5rem;
  border-radius: var(--plot-radius);
  color: var(--plot-danger);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 120ms ease;
}

.identity-sign-out:hover {
  background-color: var(--plot-surface-sunken);
}
