/* ==========================================================================
   CivNode — Attachments
   Attachment strip (inline) and tabbed modal for managing files.
   ========================================================================== */

/* ---------------------------------------------------------------------------
   Shared: file extension badge
   ------------------------------------------------------------------------- */

.att-ext {
  width: 30px;
  height: 34px;
  flex-shrink: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: visible;
}

/* Dog-ear fold on top-right */
.att-ext::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 7px;
  height: 7px;
  background: linear-gradient(225deg, var(--border) 50%, transparent 50%);
}

/* ---------------------------------------------------------------------------
   Attachment strip — rendered beneath chapter prose
   ------------------------------------------------------------------------- */

.lp-attach-strip {
  margin-top: 28px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.lp-attach-strip .att-strip-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.lp-attach-strip .att-strip-manage {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent);
  padding-bottom: 1px;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
}

.lp-attach-strip .att-strip-manage:hover {
  color: var(--text-primary);
  border-bottom-color: var(--text-primary);
}

.att-strip-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

/* Compact 1-col variant used in messages */
.att-strip-grid.att-strip-compact {
  grid-template-columns: 1fr;
}

.att-tile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  min-height: 56px;
  transition: border-color var(--transition), background var(--transition);
}

.att-tile:hover {
  border-color: var(--accent-subtle);
  background: var(--bg-elevated);
}

.att-tile .att-meta {
  min-width: 0;
  flex: 1;
}

.att-tile .att-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.att-tile .att-size {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
}

.att-tile-add {
  justify-content: center;
  background: transparent;
  border-style: dashed;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12.5px;
  gap: 6px;
}

.att-tile-add:hover {
  border-color: var(--accent);
  color: var(--text-primary);
  background: color-mix(in oklab, var(--accent) 5%, var(--bg-primary));
}

.att-tile-add .att-tile-plus {
  display: inline-block;
  width: 14px;
  height: 14px;
  background: currentColor;
  -webkit-mask-image: url('/icons/plus.png');
          mask-image: url('/icons/plus.png');
  -webkit-mask-size: contain;
          mask-size: contain;
  -webkit-mask-repeat: no-repeat;
          mask-repeat: no-repeat;
  -webkit-mask-position: center;
          mask-position: center;
}

/* ---------------------------------------------------------------------------
   Attachment modal — tabbed, with drop zone
   ------------------------------------------------------------------------- */

.att-modal-backdrop {
  position: fixed;
  inset: 0;
  background: color-mix(in oklab, var(--bg-primary) 72%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  animation: att-fade-in 120ms ease;
}

@keyframes att-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.att-modal {
  width: 620px;
  max-width: 92vw;
  max-height: 88vh;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.65);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: att-slide-up 140ms ease;
}

@keyframes att-slide-up {
  from { transform: translateY(8px); opacity: 0; }
  to   { transform: translateY(0);   opacity: 1; }
}

.att-modal-head {
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  flex-shrink: 0;
}

.att-modal-head h2 {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--text-primary);
}

.att-modal-head .att-modal-paperclip {
  display: inline-block;
  width: 16px;
  height: 16px;
  background: var(--text-muted);
  -webkit-mask-image: url('/icons/paperclip.png');
          mask-image: url('/icons/paperclip.png');
  -webkit-mask-size: contain;
          mask-size: contain;
  -webkit-mask-repeat: no-repeat;
          mask-repeat: no-repeat;
  -webkit-mask-position: center;
          mask-position: center;
}

.att-modal-close {
  margin-left: auto;
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition), background var(--transition);
}

.att-modal-close:hover {
  color: var(--text-primary);
  background: var(--bg-surface);
}

/* Tabs */

.att-tabs {
  display: flex;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  gap: 14px;
  flex-shrink: 0;
}

.att-tab {
  padding: 10px 0;
  font-family: var(--font-sans);
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
  white-space: nowrap;
}

.att-tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.att-tab:hover:not(.active) {
  color: var(--text-secondary);
}

/* Scrollable body */

.att-modal-body {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

/* Drop zone */

.att-drop {
  margin: 16px 20px 10px;
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  padding: 22px 16px;
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), color var(--transition);
}

.att-drop:hover,
.att-drop.att-drop-over {
  border-color: var(--accent);
  color: var(--text-primary);
  background: color-mix(in oklab, var(--accent) 5%, var(--bg-primary));
}

.att-drop .att-drop-big {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.att-drop .att-drop-small {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

/* Upload progress row */

.att-upload-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 20px 8px;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12.5px;
  color: var(--text-secondary);
}

.att-upload-bar {
  flex: 1;
  height: 3px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.att-upload-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 100ms linear;
  width: 0;
}

/* List of items */

.att-list-label {
  padding: 8px 20px 4px;
  font-family: var(--font-sans);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.att-list {
  padding: 4px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.att-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  transition: border-color var(--transition), background var(--transition);
}

.att-item:hover {
  border-color: var(--border);
  background: var(--bg-elevated);
}

.att-item .att-meta {
  min-width: 0;
  flex: 1;
}

.att-item .att-name {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.att-item .att-detail {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.att-item .att-host {
  font-size: 10.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.att-item .att-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.att-icon-btn {
  width: 28px;
  height: 28px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition), border-color var(--transition);
}

.att-icon-btn:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
  border-color: var(--border);
}

.att-icon-btn.att-btn-danger:hover {
  color: #c0392b;
  border-color: #c0392b;
}

.att-icon-btn-glyph {
  display: inline-block;
  width: 13px;
  height: 13px;
  background: currentColor;
  -webkit-mask-size: contain;
          mask-size: contain;
  -webkit-mask-repeat: no-repeat;
          mask-repeat: no-repeat;
  -webkit-mask-position: center;
          mask-position: center;
}

.att-icon-btn-glyph.att-glyph-download {
  -webkit-mask-image: url('/icons/download.png');
          mask-image: url('/icons/download.png');
}

.att-icon-btn-glyph.att-glyph-trash {
  -webkit-mask-image: url('/icons/trash.png');
          mask-image: url('/icons/trash.png');
}

/* Virus scan badges */

.att-scan-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 999px;
  vertical-align: middle;
}

.att-scan-badge.pending {
  background: color-mix(in oklab, var(--accent) 15%, var(--bg-elevated));
  color: var(--accent);
}

.att-scan-badge.infected {
  background: color-mix(in oklab, #c0392b 18%, var(--bg-elevated));
  color: #c0392b;
}

/* Footer */

.att-modal-foot {
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.att-usage-text {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

.att-usage-bar {
  width: 120px;
  height: 4px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.att-usage-bar-fill {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 400ms ease;
}

.att-usage-bar-fill.att-usage-warn {
  background: #c0392b;
}

.att-foot-spacer {
  flex: 1;
}

/* Empty state */

.att-empty {
  padding: 32px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13.5px;
  line-height: 1.7;
}

.att-empty strong {
  display: block;
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

/* Subscriber upgrade CTA shown to free users on upload attempt */

.att-upgrade-cta {
  margin: 12px 20px;
  padding: 14px 16px;
  background: color-mix(in oklab, var(--accent) 8%, var(--bg-elevated));
  border: 1px solid color-mix(in oklab, var(--accent) 30%, var(--border));
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.att-upgrade-cta strong {
  display: block;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.att-upgrade-cta a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Paperclip toolbar button (used in various editors) */

.toolbar-btn-paperclip {
  position: relative;
}

.toolbar-btn-paperclip .att-pending-dot {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  pointer-events: none;
}

/* Account attachments screen */

.account-attach-screen {
  max-width: 860px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

.account-attach-screen h1 {
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.account-attach-usage-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
}

.account-attach-usage-bar .att-usage-text {
  font-size: 12.5px;
}

.account-attach-filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.account-attach-filter-row select {
  font-family: var(--font-sans);
  font-size: 12.5px;
  padding: 6px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  cursor: pointer;
}

.account-attach-filter-row select:focus-visible {
  outline: none;
  border-color: var(--accent);
}

.account-attach-bulk-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text-secondary);
}

.account-attach-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.account-attach-table th {
  font-family: var(--font-sans);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.account-attach-table th:first-child {
  width: 32px;
}

.account-attach-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.account-attach-table tr:hover td {
  background: var(--bg-elevated);
}

.account-attach-table .att-row-name {
  font-weight: 600;
  color: var(--text-primary);
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-attach-table .att-row-type {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--accent);
  text-transform: uppercase;
}

.account-attach-table .att-row-size {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.account-attach-table .att-row-host a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 12px;
}

.account-attach-table .att-row-host a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.account-attach-table .att-row-date {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

.account-attach-table .att-row-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

/* Load more */

.account-attach-load-more {
  text-align: center;
  margin-top: 20px;
}
