*,
*::after,
*::before {
  box-sizing: border-box;
}

:root {
  font-size: 13px;
  --color-text: #fff;
  --color-bg: #000;
  --color-link: #fff;
  --color-link-hover: #fff;
  --page-padding: 1.5rem;
}

body {
  margin: 0;
  color: var(--color-text);
  background-color: var(--color-bg);
  font-family: 'forma-djr-mono', monospace;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-transform: uppercase;
}

a {
  text-decoration: none;
  color: var(--color-link);
  outline: none;
  cursor: pointer;

  &:hover {
    text-decoration: underline;
    color: var(--color-link-hover);
  }

  &:focus {
    outline: none;
    background: lightgrey;

    &:not(:focus-visible) {
      background: transparent;
    }

    &:focus-visible {
      outline: 2px solid red;
      background: transparent;
    }
  }
}

.frame {
  padding: 1rem var(--page-padding) 0;
  display: grid;
  z-index: 1000;
  position: relative;
  grid-row-gap: 1rem;
  grid-column-gap: 1.5rem;
  pointer-events: none;
  justify-items: start;
  grid-template-columns: auto auto auto 1fr;
  grid-template-areas:
    'title title title'
    'archive github ...'
    'tags tags tags'
    'sponsor sponsor sponsor';

  #cdawrap {
    justify-self: start;
    grid-area: sponsor;
  }

  a,
  button {
    pointer-events: auto;
  }

  .frame__title {
    grid-area: title;
    font-size: inherit;
    margin: 0;
  }

  .frame__back {
    grid-area: back;
    justify-self: start;
  }

  .frame__archive {
    grid-area: archive;
    justify-self: start;
  }

  .frame__nav-links {
    grid-area: archive;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
  }

  .frame__github {
    grid-area: github;
  }

  .frame__tags {
    grid-area: tags;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
  }

  .frame__demos {
    grid-area: demos;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
  }

  @media screen and (min-width: 53em) {
    padding: var(--page-padding);
    position: fixed;
    height: 100vh;
    top: 0;
    left: 0;
    width: 100%;
    grid-template-columns: auto auto auto auto 1fr;
    grid-template-rows: auto auto;
    align-content: space-between;
    grid-template-areas:
      'title back github archive sponsor'
      'tags tags tags tags ...';

    .frame__tags {
      align-self: end;
    }

    .frame__demos,
    #cdawrap {
      justify-self: end;
      text-align: right;
      max-width: 250px;
    }
  }
}

/* Dashboard layout tweaks */
.dashboard-page .frame {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: auto;
  padding: 1rem var(--page-padding);
  background: #000;
  align-content: flex-start;
}

.dashboard-page .frame__tags {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  padding: 0.75rem var(--page-padding);
  background: #000;
  border-top: 1px solid #222;
  justify-content: center;
}

.dashboard-page .dashboard-main {
  padding-top: 5rem;
  padding-bottom: 4rem;
}

.content {
  padding: 100vh var(--page-padding) 25vh;
}

.group {
  display: grid;
  margin-bottom: 10vh;
  display: flex;
  flex-direction: column;
  flex: 1 1 100px;
}

.el {
  white-space: nowrap;
  filter: blur(0px);
  text-transform: uppercase;
  opacity: 0.6;
}

.el--xl {
  font-size: clamp(2rem, 20vw, 15rem);
  opacity: 1;
  font-family: 'lores-12', sans-serif;
  font-weight: 400;
}

.pos-2 {
  margin-left: 25vw;
}

.pos-3 {
  margin-left: 70vw;
}

.pos-4 {
  margin-left: auto;
}

.pos-5 {
  margin-top: 200px;
  opacity: 1;
}

.pos-6 {
  margin-left: auto;
  margin-top: 200px;
  opacity: 1;
}

.pos-7 {
  margin-top: 200px;
  opacity: 1;
  filter: blur(1.2px);
}

.pos-8 {
  margin-left: 25vw;
  margin-top: 50px;
  opacity: 1;
  filter: blur(2px);
}

.pos-9 {
  margin-left: 25vw;
  margin-top: 250px;
}

.pos-10 {
  margin-left: 70vw;
  margin-top: 40vh;
}

.logo {
  font-size: clamp(2rem, 10vw, 4rem);
  font-family: 'lores-12', sans-serif;
  font-weight: 400;
}

@keyframes blink-cursor {
  from,
  to {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

.typing-indicator {
  display: inline-block;
  animation: blink-cursor 0.7s linear infinite;
}

.fixed {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100vh;
  pointer-events: none;
  position: fixed;
  left: 0;
  top: 0;
}

.logo a {
  pointer-events: auto;
}

.dashboard-main {
  padding: 8rem var(--page-padding) 4rem;
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  font-size: 1.15rem;
}

.dashboard-panel,
.dashboard-table {
  background: #111;
  border-radius: 14px;
  padding: 2rem;
  flex: 1 1 320px;
  transition: box-shadow 0.25s ease, transform 0.25s ease, border-color 0.25s ease;
  border: 1px solid transparent;
}

.dashboard-panel:hover,
.dashboard-table:hover {
  box-shadow: 0 0 0 1px #333, 0 8px 24px rgba(0, 0, 0, 0.4);
  transform: translateY(-2px);
}

.dashboard-panel h2,
.dashboard-table h2 {
  margin-top: 0;
  margin-bottom: 1.75rem;
  font-size: 1.15rem;
}

.dashboard-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.dashboard-form label {
  font-size: 0.85rem;
  opacity: 0.8;
}

.dashboard-form input,
.dashboard-form select,
.dashboard-form textarea,
.dashboard-form button {
  font-family: inherit;
  font-size: 0.95rem;
  text-transform: uppercase;
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  border: 1px solid #333;
  background: #000;
  color: #fff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.dashboard-form input:hover:not(:disabled),
.dashboard-form select:hover:not(:disabled),
.dashboard-form textarea:hover:not(:disabled) {
  border-color: #555;
}

.dashboard-form input:focus,
.dashboard-form select:focus,
.dashboard-form textarea:focus {
  outline: none;
  border-color: #5fcb88;
  box-shadow: 0 0 0 2px rgba(95, 203, 136, 0.2);
}

.dashboard-form button {
  cursor: pointer;
  border-color: #666;
}

.dashboard-form input:disabled,
.dashboard-form select:disabled,
.dashboard-form button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.dashboard-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.dashboard-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

#flows-table {
  table-layout: fixed;
}

#flows-table .flow-col-wallet { width: 14%; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
#flows-table .flow-col-token { width: 12%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#flows-table .flow-col-chain { width: 10%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#flows-table .flow-col-pattern { width: 52%; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
#flows-table .flow-col-risk { width: 12%; min-width: 0; }

#tokens-table {
  table-layout: fixed;
  width: 100%;
}

#tokens-table thead {
  display: table;
  width: 100%;
  table-layout: fixed;
}

#tokens-table tbody {
  display: block;
  max-height: 220px;
  overflow-y: auto;
}

#tokens-table tbody tr {
  display: table;
  width: 100%;
  table-layout: fixed;
}

#tokens-table .col-logo {
  width: 8%;
  min-width: 2.5rem;
  box-sizing: border-box;
}

#tokens-table .col-name {
  width: 15%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#tokens-table .col-mc {
  width: 12%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#tokens-table .col-pattern {
  width: 49%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

#tokens-table .col-links {
  width: 16%;
  min-width: 0;
}

.dashboard-table th,
.dashboard-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid #222;
  text-align: left;
}

.dashboard-table th {
  opacity: 0.7;
}

#flows-table tbody tr,
#tokens-table tbody tr {
  transition: background 0.2s ease;
}

#flows-table tbody tr:hover,
#tokens-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.04);
}

.dashboard-table a {
  transition: color 0.2s ease, opacity 0.2s ease;
}

.dashboard-table a:hover {
  opacity: 1;
  color: #5fcb88;
}

.token-logo-cell {
  width: 2.5rem;
  padding: 0.4rem 0.5rem;
  vertical-align: middle;
}

.token-logo-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.token-logo {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  transition: transform 0.25s ease;
}

#tokens-table tbody tr:hover .token-logo {
  transform: scale(1.15);
}

.token-logo-fallback {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #333;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
}

.risk-low {
  color: #5fcb88;
}

.risk-medium {
  color: #f2c94c;
}

.risk-high {
  color: #eb5757;
}

.phantom-button {
  margin-bottom: 0.75rem;
  padding: 0.6rem 0.9rem;
  border-radius: 999px;
  border: 1px solid #5fcb88;
  background: transparent;
  color: #5fcb88;
  font-size: 0.85rem;
  text-transform: uppercase;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.phantom-button:hover:not(:disabled) {
  transform: scale(1.03);
  box-shadow: 0 0 16px rgba(95, 203, 136, 0.35);
}

.phantom-button:active:not(:disabled) {
  transform: scale(0.98);
}

.phantom-button--connected {
  background: #5fcb88;
  color: #000;
}

.phantom-button--connected:hover {
  box-shadow: 0 0 20px rgba(95, 203, 136, 0.5);
}

.phantom-status {
  font-size: 0.75rem;
  opacity: 0.8;
  margin-bottom: 1.25rem;
  word-break: break-all;
}

.dashboard-hint {
  font-size: 0.75rem;
  opacity: 0.7;
  margin-top: 0;
  margin-bottom: 1rem;
  text-transform: none;
}

.dashboard-section-title {
  margin-top: 1.5rem;
}

.dashboard-panel--simulate .dashboard-form {
  margin-top: 0;
}

.dashboard-form textarea {
  resize: vertical;
  min-height: 2.5rem;
  width: 100%;
  box-sizing: border-box;
}

.dashboard-button-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.dashboard-btn {
  padding: 0.5rem 1rem;
  border-radius: 6px;
  border: 1px solid #333;
  background: #000;
  color: #fff;
  font-family: inherit;
  font-size: 0.85rem;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.dashboard-btn:hover:not(:disabled) {
  transform: scale(1.02);
  border-color: #555;
  background: #1a1a1a;
}

.dashboard-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.dashboard-btn--secondary {
  border-color: #555;
  color: #ccc;
}

.dashboard-btn--secondary:hover:not(:disabled) {
  border-color: #777;
  color: #fff;
}

.dashboard-btn--small {
  padding: 0.35rem 0.6rem;
  font-size: 0.75rem;
  margin-left: 0.5rem;
}

.sim-fees {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #222;
  font-size: 0.85rem;
}

.sim-fees-label {
  opacity: 0.8;
  margin-right: 0.5rem;
}

.sim-log {
  max-height: 220px;
  overflow-y: auto;
  padding: 0.75rem;
  background: #000;
  border-radius: 6px;
  font-size: 0.75rem;
  font-family: monospace;
  margin-bottom: 0.75rem;
}

.sim-log-line {
  margin-bottom: 0.25rem;
  word-break: break-all;
  transition: opacity 0.2s ease;
}

.sim-log-line--new {
  animation: sim-log-in 0.35s ease forwards;
}

@keyframes sim-log-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.sim-log-line--step {
  opacity: 0.85;
}

.sim-log-line--ok {
  color: #5fcb88;
}

.dashboard-table--logs {
  flex: 1 1 100%;
}

.related {
  container-type: inline-size;
}

.related p {
  text-align: center;
  padding-top: 3rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  padding: 5rem var(--page-padding) 10vh;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
}

/* Grid item (the link) */
.grid__item {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  border-radius: 12px;
  overflow: hidden;
  background: #111;
}

/* Image block */
.grid__item-img {
  width: 100%;
  aspect-ratio: 4 / 3;
  background-size: cover;
  background-position: center;
  opacity: 0.4;
  transition: all 0.5s ease;
}

/* Subtle zoom on hover */
.grid__item:hover .grid__item-img {
  transform: scale(1.1);
  opacity: 1;
}

/* Title */
.grid__item-title {
  padding: 1rem;
  font-size: 0.95rem;
  font-weight: 400;
  line-height: 1.4;
}

/* Optional: nicer focus state for accessibility */
.grid__item:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 4px;
}

@container (max-width: 800px) {
  .grid {
    grid-template-columns: 1fr;
  }
  .grid__item-img {
    display: none;
  }
  .grid__item-title {
    padding: 0.25rem;
    line-height: 1;
  }
}
