/*
 * CIPNFT UI — "CIPHER" design system (exactly matching the provided layout)
 * Shared stylesheet used by all pages.
 */

:root {
  --bg-color: #ffffff;
  --text-main: #0a0a0a;
  --text-muted: #888888;
  --accent: #0044ff; /* International Klein Blue for strict tech feel */
  --border: #e0e0e0;
  --surface: #fcfcfc;
  --grid-color: rgba(0, 0, 0, 0.03);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.6;
  overflow-x: hidden;
}

/* Typography */
h1, h2, h3 {
  font-weight: 600;
  letter-spacing: -0.03em;
}

.mono {
  font-family: 'Space Mono', monospace;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Background Grid */
.grid-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-image: linear-gradient(var(--grid-color) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
  background-size: 40px 40px;
  z-index: -1;
  pointer-events: none;
}

/* Navigation */
nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2rem 5%;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-family: 'Space Mono', monospace;
  font-weight: 700;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo span {
  width: 10px;
  height: 10px;
  background: var(--accent);
  display: inline-block;
}

.nav-links {
  display: flex;
  gap: 2rem;
}

.nav-links a {
  text-decoration: none;
  color: var(--text-main);
  font-size: 0.9rem;
  transition: color 0.3s ease;
}

.nav-links a:hover {
  color: var(--accent);
}

.nav-toggle {
  display: none;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.6);
  backdrop-filter: blur(8px);
  border-radius: 12px;
  padding: 0.55rem 0.8rem;
  font-family: 'Space Mono', monospace;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text-main);
}

.nav-toggle:hover { border-color: rgba(0,68,255,0.25); }

.btn {
  padding: 0.8rem 1.5rem;
  border: 1px solid var(--text-main);
  background: transparent;
  color: var(--text-main);
  cursor: pointer;
  font-family: 'Space Mono', monospace;
  font-size: 0.8rem;
  transition: all 0.3s ease;
}

.btn:hover {
  background: var(--text-main);
  color: var(--bg-color);
}

.wallet-box {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.wallet-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.1;
  user-select: none;
}

.wallet-link {
  font-size: 0.7rem;
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(0,0,0,0.18);
  line-height: 1.1;
}

.wallet-link:hover {
  border-bottom-color: var(--text-main);
}

.btn.primary {
  background: var(--text-main);
  color: white;
}

.btn.primary:hover {
  background: #000;
  color: white;
}

.btn.small {
  padding: 0.6rem 1.1rem;
  font-size: 0.75rem;
}

/* Hide transaction/action controls until wallet is connected */
body:not(.wallet-connected) .requires-wallet{
  display:none !important;
}

/* Strict mode requested: before wallet connect, hide *all* buttons/btn-links
   except those explicitly marked as allowed. */
body:not(.wallet-connected) button.btn:not(.allow-disconnected),
body:not(.wallet-connected) a.btn:not(.allow-disconnected){
  display:none !important;
}

/* Hero Section */
header {
  height: 90vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 5%;
  position: relative;
}

/* ---- App console header (index.html) ---- */
header.app-header{
  height: auto;
  padding: 2.5rem 5% 0 5%;
  justify-content: flex-start;
}
header.app-header .status-bar{
  position: static;
  margin-bottom: 1rem;
}
header.app-header h1{
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  margin-bottom: 1rem;
  max-width: 1000px;
}
header.app-header .hero-desc{
  max-width: 760px;
  margin-bottom: 0;
}

.status-bar {
  position: absolute;
  top: 2rem;
  left: 5%;
  color: var(--text-muted);
}

h1 {
  font-size: clamp(3rem, 8vw, 6rem);
  line-height: 1.1;
  margin-bottom: 2rem;
  max-width: 900px;
}

.hero-desc {
  max-width: 500px;
  color: var(--text-muted);
  margin-bottom: 3rem;
}

/* Encryption Visuals */
.hash-stream {
  position: absolute;
  right: 5%;
  top: 30%;
  font-family: 'Space Mono', monospace;
  color: #e0e0e0;
  font-size: 0.8rem;
  line-height: 1.8;
  user-select: none;
  z-index: -1;
  text-align: right;
  display: none; /* Hidden on mobile */
}

@media (min-width: 768px) {
  .hash-stream {
    display: block;
  }
}

/* Stats Section */
.stats-bar {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 2rem 5%;
  background: var(--surface);
  gap: 1rem;
  flex-wrap: wrap;
}

.stat-item h3 {
  font-size: 2rem;
  font-family: 'Space Mono', monospace;
}

.stat-item p {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* Showcase / Marketplace */
.showcase {
  padding: 5rem 5%;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 3rem;
  gap: 2rem;
  flex-wrap: wrap;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
}

/* Two-up grids used by the 2-page flow (e.g. Marketplace offers panels) */
.grid.dual{
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (max-width: 900px) {
  .grid.dual{ grid-template-columns: 1fr; }
}

/* Page-specific grid modifiers */
.grid.stack {
  grid-template-columns: 1fr !important;
}

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

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

@media (max-width: 768px) {
  .grid.market {
    grid-template-columns: 1fr;
  }
}

/* ---- App console layout (index.html) ---- */
.app-layout{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  align-items: start;
}

.app-col{
  display: flex;
  flex-direction: column;
  gap: 2rem;
  min-width: 0;
}

.app-bottom{
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  min-width: 0;
}

@media (max-width: 1100px) {
  .app-layout{ grid-template-columns: 1fr; }
}

/* (note) responsive overrides for .grid.dual are defined above */


.card {
  border: 1px solid var(--border);
  background: #fff;
  padding: 1.5rem;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  position: relative;
  overflow: hidden;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.05);
  border-color: var(--text-main);
}

.card-image {
  height: 250px;
  background: #f0f0f0;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* The Encrypted Blur Effect */
.encrypted-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><rect fill="rgba(0,0,0,0.05)" x="0" y="0" width="100" height="100"/></svg>');
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.4s ease;
}

.card:hover .encrypted-layer {
  opacity: 0; /* Reveal on hover */
}

.lock-icon {
  font-size: 2rem;
  color: var(--text-muted);
}

.card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  gap: 1rem;
}

/* Technical Diagram Section */
.tech-stack {
  background: var(--text-main);
  color: var(--bg-color);
  padding: 5rem 5%;
}

.tech-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4rem;
  align-items: center;
}

.tech-list li {
  list-style: none;
  border-bottom: 1px solid #333;
  padding: 1.5rem 0;
  display: flex;
  justify-content: space-between;
}

.tech-list span.status {
  color: #00ff88; /* Tech Green */
  font-family: 'Space Mono', monospace;
}

/* Footer */
footer {
  padding: 3rem 5%;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 2rem;
}

/* Responsive */
@media (max-width: 768px) {
  .tech-grid {
    grid-template-columns: 1fr;
  }
  h1 {
    font-size: 2.5rem;
  }
  nav {
    padding: 1rem 5%;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-start;
  }
  .logo { order: 1; }
  .nav-toggle { order: 2; margin-left: auto; }
  .wallet-box {
    order: 3;
    width: 100%;
    align-items: flex-start;
    flex-direction: row;
    justify-content: space-between;
    gap: 0.75rem;
  }
  .wallet-box .btn {
    padding: 0.6rem 0.9rem;
    font-size: 0.75rem;
    white-space: nowrap;
  }
  .wallet-sub, .wallet-link {
    font-size: 0.65rem;
    line-height: 1.05;
  }
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .nav-links { display: none; }

  nav.nav-open .nav-links {
    display: flex;
    flex-direction: column;
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    background: rgba(255,255,255,0.98);
    border-bottom: 1px solid var(--border);
    padding: 1rem 5%;
    gap: 1rem;
  }
}

/* Utility for scramble effect */
.cipher-text {
  display: inline-block;
  min-width: 100px;
}

/* ---------------- CIPNFT app utilities (additive; does not alter base design) ---------------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.02);
  font-family: 'Space Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.pill.ok {
  border-color: rgba(0, 68, 255, 0.25);
  color: var(--accent);
}

.pill.warn {
  border-color: rgba(255, 180, 0, 0.35);
  color: #b26a00;
}

.pill.bad {
  border-color: rgba(255, 0, 0, 0.22);
  color: #b00020;
}

label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-family: 'Space Mono', monospace;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

input,
textarea,
select {
  width: 100%;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-main);
  outline: none;
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
}

textarea {
  min-height: 220px;
  resize: vertical;
}

input[readonly] {
  background: #fafafa;
}

.row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.row3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1rem;
}

.actions {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 1rem;
}

.hint {
  max-width: 720px;
  color: var(--text-muted);
  margin-top: 0.75rem;
  font-size: 0.95rem;
}

.status {
  color: var(--text-muted);
  margin-top: 0.9rem;
  font-size: 0.95rem;
}

.mono-line {
  font-family: 'Space Mono', monospace;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.console {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 1rem;
  height: 220px;
  overflow: auto;
  font-family: 'Space Mono', monospace;
  font-size: 0.8rem;
  white-space: pre-wrap;
}

.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

.table th,
.table td {
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 0;
  text-align: left;
  vertical-align: top;
  font-size: 0.95rem;
}

.table th {
  font-family: 'Space Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.kv {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 0.5rem 1rem;
  margin-top: 1rem;
}

.kv div:nth-child(odd) {
  font-family: 'Space Mono', monospace;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.kv div:nth-child(even) {
  font-family: 'Space Mono', monospace;
  font-size: 0.85rem;
  color: var(--text-main);
  word-break: break-word;
}

.link {
  color: var(--text-main);
  text-decoration: none;
  border-bottom: 1px solid var(--text-main);
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 1.25rem 0;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  padding: 0.8rem 1.1rem;
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--border);
  box-shadow: 0 20px 40px rgba(0,0,0,0.08);
  backdrop-filter: blur(10px);
  font-family: 'Space Mono', monospace;
  font-size: 0.8rem;
  z-index: 999;
  display: none;
}

.toast.show { display: block; }

/* ---- Modal (CIPNFT confirm popups) ---- */
.cipnft-modal-backdrop{
  position: fixed;
  inset: 0;
  padding: 22px;
  background: rgba(0,0,0,0.42);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.cipnft-modal-backdrop.show{ display:flex; }

.cipnft-modal{
  width: min(560px, 100%);
  background: rgba(255,255,255,0.96);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.18);
  backdrop-filter: blur(10px);
}

.cipnft-modal-head{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 12px;
}

.cipnft-modal-title{
  font-family: 'Space Mono', monospace;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.cipnft-modal-body{
  margin-top: 12px;
  color: var(--text-main);
  line-height: 1.55;
}

.cipnft-modal-actions{
  margin-top: 16px;
  display:flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

body.cipnft-modal-open{
  overflow: hidden;
}

/* Terms markup rendering */
.tos-markup{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  line-height: 1.55;
  color: var(--text-main);
  overflow-wrap: anywhere;
}
.tos-markup p{ margin: 0 0 12px 0; }
.tos-markup h1,.tos-markup h2,.tos-markup h3{ margin: 0 0 10px 0; }
.tos-markup .tos-title{ font-size: 1.35rem; }
.tos-markup .tos-sec{ font-size: 1.05rem; margin-top: 14px; }
.tos-markup .tos-head{ font-size: 0.95rem; margin-top: 12px; letter-spacing: 0.02em; }
.tos-markup ul,.tos-markup ol{ margin: 0 0 12px 22px; }
.tos-markup li{ margin: 4px 0; }
.tos-markup code{ font-family: var(--mono); font-size: 0.95em; }

/* Div-based table rows used by Marketplace / Verify pages */
.table-row {
  display: grid;
  grid-template-columns: 1.2fr 0.9fr 1.1fr 0.9fr auto;
  gap: 12px;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.table-row.compact {
  grid-template-columns: 1.0fr 1.1fr 1.1fr auto;
}

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

.table-row input.inline {
  padding: 0.6rem 0.7rem;
  font-size: 0.9rem;
}

.danger {
  border-color: rgba(255, 0, 0, 0.35) !important;
  color: #b00020 !important;
}

.danger:hover {
  background: #b00020 !important;
  color: #fff !important;
}

/* Advanced disclosure blocks (used for optional/unsafe actions) */
details.advanced {
  margin-top: 1rem;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.02);
  padding: 0.9rem 1rem;
}

details.advanced > summary {
  cursor: pointer;
  user-select: none;
}

details.advanced > summary::-webkit-details-marker {
  display: none;
}

.advanced-body {
  margin-top: 0.75rem;
}

.advanced-warn {
  color: #b00020;
  border-left: 3px solid rgba(255, 0, 0, 0.35);
  padding-left: 0.75rem;
  line-height: 1.5;
}


/* Cipher hover toggle state (menus) */
a.logo {
  text-decoration: none;
  color: var(--text-main);
}

a.logo:visited {
  color: var(--text-main);
}

a.logo:hover {
  color: var(--text-main);
}

.nav-links a.is-encrypted {
  color: var(--accent) !important;
}

.footer-legal {
  max-width: 520px;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.6;
}

.footer-legal a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid rgba(0,0,0,0.25);
}

.footer-legal a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}


/* Responsive tables: collapse div-table rows on narrow screens */
@media (max-width: 900px) {
  .table-row {
    grid-template-columns: 1fr !important;
    gap: 6px;
    align-items: start;
  }
  .table-row .actions-inline {
    justify-content: flex-start;
  }
}

/* Verify page ciphertext preview */
.cipher-box{
  background: rgba(2,6,23,.04);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  font-size: .78rem;
  line-height: 1.25rem;
  color: var(--text-muted);
  word-break: break-all;
  max-height: 140px;
  overflow: auto;
}

