/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

:root {
  --bg: #f6f3ed;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --ink: #252525;
  --muted: #6c675f;
  --line: #ded7cc;
  --work: #2f7a67;
  --personal: #c25a3b;
  --accent: #2b6f9c;
  --warning: #b7791f;
  --danger: #a83f39;
  --shadow: 0 18px 45px rgba(46, 38, 26, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.92), rgba(246, 243, 237, 0.96)),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

a {
  color: inherit;
}

button,
input,
textarea,
select {
  font: inherit;
}

.app-frame {
  min-height: 100vh;
}

/* The top bar keeps navigation and Devise session actions visible everywhere. */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px clamp(18px, 4vw, 42px);
  border-bottom: 1px solid rgba(222, 215, 204, 0.8);
  background: rgba(255, 253, 248, 0.9);
  backdrop-filter: blur(14px);
}

.brand-mark {
  color: var(--ink);
  font-size: 1.2rem;
  font-weight: 800;
  text-decoration: none;
}

.account-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 0.92rem;
}

.workspace {
  width: min(1420px, 100%);
  margin: 0 auto;
  padding: 28px clamp(18px, 4vw, 42px) 60px;
}

.workspace-intro {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.workspace-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-top: 30px;
}

.workspace-intro h1,
.auth-panel h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(2rem, 5vw, 4.2rem);
  line-height: 1;
}

.eyebrow,
.modal-kicker,
.date-line {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.lede {
  max-width: 650px;
  margin: 10px 0 0;
  color: var(--muted);
}

.blocks-grid {
  display: grid;
  grid-template-columns: 1fr;
  grid-auto-flow: row;
  grid-auto-rows: 2px;
  column-gap: 20px;
  row-gap: 0;
  align-items: start;
}

.block-card {
  position: relative;
  width: 100%;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  box-shadow: 0 10px 22px rgba(46, 38, 26, 0.07);
  cursor: default;
  transition: transform 150ms ease, box-shadow 150ms ease, opacity 150ms ease;
}

.block-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 32px rgba(46, 38, 26, 0.11);
}

.block-card.is-dragging {
  opacity: 0.9;
  transform: rotate(0.6deg);
  cursor: grabbing;
  box-shadow: 0 24px 54px rgba(46, 38, 26, 0.22);
}

.block-card-placeholder {
  width: 100%;
  min-height: 180px;
  border: 2px dashed rgba(47, 122, 103, 0.5);
  border-radius: 8px;
  background: rgba(47, 122, 103, 0.08);
}

.category-work {
  border-color: var(--work);
}

.category-personal {
  border-color: var(--personal);
}

.block-card-link {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
  color: inherit;
  cursor: pointer;
  text-decoration: none;
}

.card-topline,
.modal-header,
.section-header,
.form-actions,
.field-row,
.item-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-topline,
.modal-header,
.section-header {
  justify-content: space-between;
}

.card-topline {
  padding-right: 42px;
}

.drag-handle {
  position: absolute;
  top: 18px;
  right: 18px;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  cursor: grab;
  touch-action: none;
}

.drag-handle:hover,
.drag-handle:focus-visible {
  border-color: var(--line);
  background: rgba(249, 246, 239, 0.88);
}

.drag-handle:active {
  cursor: grabbing;
}

.drag-handle-dots,
.drag-handle-dots::before,
.drag-handle-dots::after {
  display: block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 8px 0 0 var(--muted);
}

.drag-handle-dots {
  position: relative;
}

.drag-handle-dots::before,
.drag-handle-dots::after {
  position: absolute;
  left: 0;
  content: "";
}

.drag-handle-dots::before {
  top: -8px;
}

.drag-handle-dots::after {
  top: 8px;
}

body.is-sorting-blocks {
  cursor: grabbing;
  user-select: none;
}

.block-card h2 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 1.45rem;
  line-height: 1.2;
}

.brief-preview {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.card-preview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.card-preview-section {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(249, 246, 239, 0.64);
}

.card-preview-section h3 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 0.82rem;
}

.card-preview-list {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.card-preview-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 7px;
  color: var(--ink);
  font-size: 0.84rem;
  line-height: 1.25;
}

.card-preview-item span:not(.preview-marker),
.card-preview-item small {
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-preview-item small {
  grid-column: 2;
  color: var(--muted);
  font-size: 0.74rem;
  white-space: nowrap;
}

.preview-marker {
  width: 8px;
  height: 8px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--accent);
}

.preview-marker.is-complete {
  background: var(--work);
}

.card-preview-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.card-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.card-metrics span,
.status-pill,
.section-header span {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f9f6ef;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.importance-dot {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
}

.importance-low .importance-dot {
  background: #8a9487;
}

.importance-medium .importance-dot {
  background: var(--accent);
}

.importance-high .importance-dot {
  background: var(--warning);
}

.importance-critical .importance-dot {
  background: var(--danger);
}

.empty-board,
.auth-panel {
  margin-top: 28px;
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.7);
}

.empty-board h2,
.empty-board p {
  margin: 0;
}

.empty-board p {
  margin-top: 8px;
  color: var(--muted);
}

/* Forms share compact structure because blocks should feel quick to update. */
.block-form,
.inline-form,
.auth-form {
  display: grid;
  gap: 12px;
}

.field-row {
  flex-wrap: wrap;
  align-items: flex-end;
}

.field-group {
  display: grid;
  flex: 1 1 160px;
  gap: 5px;
}

.field-grow {
  min-width: min(100%, 280px);
}

label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="date"],
textarea,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-strong);
  color: var(--ink);
  padding: 9px 10px;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(43, 111, 156, 0.16);
}

.primary-button,
.secondary-button,
.danger-button,
.text-button,
.small-button,
.small-primary-button,
.small-danger-button,
.icon-button {
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
}

.primary-button,
.small-primary-button {
  background: var(--ink);
  color: var(--surface);
}

.secondary-button,
.small-button {
  border-color: var(--line);
  background: var(--surface-strong);
  color: var(--ink);
}

.danger-button,
.small-danger-button {
  border-color: rgba(168, 63, 57, 0.2);
  background: rgba(168, 63, 57, 0.08);
  color: var(--danger);
}

.text-button {
  background: transparent;
  color: var(--muted);
  padding-inline: 0;
}

.small-button,
.small-primary-button,
.small-danger-button {
  min-height: 30px;
  padding: 5px 8px;
  font-size: 0.78rem;
}

.icon-button {
  width: 36px;
  min-width: 36px;
  padding: 0;
  border-color: var(--line);
  background: var(--surface-strong);
  color: var(--muted);
}

.form-errors,
.inline-error,
.flash-alert {
  color: var(--danger);
}

.inline-error,
.form-errors p {
  margin: 0;
  font-weight: 700;
}

.flash-stack {
  position: fixed;
  top: 70px;
  right: 24px;
  z-index: 20;
  display: grid;
  gap: 8px;
}

.flash {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.flash-notice {
  color: var(--work);
}

/* Native dialog supplies modal behavior; CSS focuses on layout and legibility. */
.modal {
  width: min(1120px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  border: 0;
  border-radius: 8px;
  background: transparent;
  padding: 0;
}

.modal::backdrop {
  background: rgba(25, 22, 18, 0.48);
}

/* Drawers hold add/edit forms one level deeper than the reading surfaces. */
.drawer-dialog {
  width: 100vw;
  max-width: none;
  height: 100vh;
  max-height: none;
  margin: 0;
  border: 0;
  background: transparent;
  padding: 0;
}

.drawer-dialog::backdrop {
  background: rgba(25, 22, 18, 0.3);
}

.drawer-panel {
  width: min(480px, 100vw);
  min-height: 100vh;
  margin-left: auto;
  overflow: auto;
  padding: clamp(18px, 3vw, 28px);
  border-left: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.drawer-header h2 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 1.65rem;
  line-height: 1.1;
}

.modal-panel {
  max-height: calc(100vh - 28px);
  overflow: auto;
  padding: clamp(18px, 3vw, 28px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.modal-panel-narrow {
  width: min(720px, calc(100vw - 28px));
}

.modal-header {
  align-items: flex-start;
  margin-bottom: 22px;
}

.modal-header h2 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: clamp(1.6rem, 3vw, 2.5rem);
  line-height: 1.05;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.modal-actions form,
.item-actions form,
.account-strip form {
  margin: 0;
}

.modal-kicker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.detail-section {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
}

.brief-section {
  /* Brief lives above the grid, so it needs its own gap from the list panels. */
  margin-bottom: 14px;
}

.detail-section h3 {
  margin: 0;
  font-size: 1rem;
}

.detail-copy {
  margin: 10px 0 0;
  color: var(--muted);
}

.list-stack {
  display: grid;
  gap: 10px;
  margin: 12px 0;
}

.list-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.list-item h4,
.list-item p {
  margin: 0;
}

.list-item p {
  color: var(--muted);
}

.list-item p + p,
.resource-link + p {
  margin-top: 6px;
}

.resource-link {
  display: inline-block;
  max-width: 100%;
  overflow-wrap: anywhere;
  color: var(--accent);
  font-size: 0.9rem;
}

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

.todo-item.is-complete h4 {
  color: var(--muted);
  text-decoration: line-through;
}

.todo-content p {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
  font-size: 0.84rem;
}

.check-form {
  padding-top: 2px;
}

.check-form input[type="checkbox"],
.check-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--work);
}

.check-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  color: var(--ink);
}

.item-actions {
  justify-content: end;
  flex-wrap: wrap;
}

.empty-list {
  margin: 0;
  color: var(--muted);
}

.auth-wrap {
  display: grid;
  min-height: calc(100vh - 72px);
  place-items: center;
  padding: 24px;
}

.auth-panel {
  width: min(460px, 100%);
  margin: 0;
  border-style: solid;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.auth-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

@media (min-width: 720px) {
  .blocks-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1000px) {
  .blocks-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .top-bar,
  .account-strip,
  .modal-header,
  .list-item,
  .todo-item {
    align-items: stretch;
  }

  .top-bar,
  .workspace-intro,
  .modal-header,
  .account-strip {
    flex-direction: column;
  }

  .workspace-actions {
    justify-content: flex-start;
    padding-top: 0;
  }

  .top-bar {
    position: static;
  }

  .drawer-panel {
    width: 100vw;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .block-card,
  .block-card-link {
    min-height: auto;
  }

  .card-preview-grid {
    grid-template-columns: 1fr;
  }

  .list-item,
  .todo-item {
    grid-template-columns: 1fr;
  }

  .modal-actions,
  .item-actions {
    justify-content: flex-start;
  }

  .flash-stack {
    position: static;
    margin: 14px 18px 0;
  }
}
