/* Cipherchain V4.20 */

/* ---------------------------------------
   GLOBAL STYLES
--------------------------------------- */
html, body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
               Arial, "Noto Sans", "Liberation Sans", sans-serif;
  background: #0c0c0c;
  color: #ffffff;
  margin: 0;
  padding: 0px;
  display: block;
  justify-content: center;
}

h1, h2, label {
  font-weight: 700;
  color: #f7931a;
}

input, select, textarea, button, p, span, div {
  font-family: inherit;
}

.code, .mono, pre, code, kbd, samp {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas,
               "Liberation Mono", "Courier New", monospace;
}

/* ---------------------------------------
   SHARED CONTAINER STYLES
--------------------------------------- */
.container {
  background: #1a1a1a;
  max-width: 700px;
  width: 100%;
  padding: 30px;
  border-radius: 10px;
  box-shadow: 0 5px 20px rgba(0,0,0,0.5);
}

/* ---------------------------------------
   NAVIGATION STYLES
--------------------------------------- */

/* Simple full-width header */
.site-header {
  position: sticky;
  top: 0;
  width: 100%;
  z-index: 1000;
  margin-bottom: 60px;
  background: linear-gradient(180deg, rgba(12,12,12,.9), rgba(12,12,12,.6));
  border-bottom: 1px solid #161a1f;
  backdrop-filter: saturate(130%) blur(6px);
}

/* Center inner content */
.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: .8rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Brand */
.brand {
  display: flex;
  align-items: center;
  gap: .5rem;
}
/* Brand logo styling */
.brand-logo img {
  display: block;
  height: 48px;
  padding: 2px;
  width: auto;
}

/* Nav links */
.nav {
  display: flex;
  gap: 1rem;
  align-items: center;
}
.nav a {
  text-decoration: none;
  font-weight: 600;
}
.nav a:not(.btn) {
  color: #a9b0b7;
}
.nav a:not(.btn):hover {
  color: #e9edf1;
}

/* Button */
.btn {
  padding: .55rem .9rem;
  border-radius: 10px;
  font-weight: 700;
  background: linear-gradient(180deg,#f7931a,#ffb65a);
  box-shadow: 0 6px 18px rgba(247,147,26,.35);
  color: #000;
  text-decoration: none;
  transition: transform .15s ease, box-shadow .2s ease, color .15s ease;
}
.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(247,147,26,.4);
  color: #000;
}

/* --- Responsive nav --- */
@media (max-width: 720px){
  .nav-inner{
    flex-direction: column;
    align-items: stretch;
    gap: .75rem;
  }

  .brand{
    justify-content: center;
  }

  .nav{
    justify-content: center;
    flex-wrap: wrap;
    gap: 1rem;
  }

  .nav .btn.btn-small{
    align-self: center;
    text-align: center;
  }
}

/* ---------------------------------------
   HOME PAGE STYLES
--------------------------------------- */
.home-container {
  text-align: center;
  padding-top: 100px;
}

.home-buttons {
  margin-top: 40px;
}

.home-button {
  display: inline-block;
  padding: 14px 28px;
  margin: 15px;
  background-color: #f7931a;
  color: #0c0c0c;
  font-weight: bold;
  text-decoration: none;
  border-radius: 6px;
  font-size: 18px;
  transition: background-color 0.3s ease;
}

.home-button:hover {
  background-color: #e67e00;
}

/* ---------------------------------------
   FORM CONTROLS
--------------------------------------- */
label {
  margin-top: 20px;
  display: block;
}

input[type="file"],
input[type="number"],
select,
button,
textarea {
  width: 100%;
  margin-top: 5px;
  padding: 10px;
  font-size: 16px;
  border-radius: 5px;
  box-sizing: border-box;
}

input[type="number"],
textarea {
  border: 1px solid #4d4d4d;
  background-color: #0c0c0c;
  color: #ffffff;
}

input[type="number"]:focus,
textarea:focus {
  outline: none;
  border-color: #f7931a;
}

/* ---------------------------------------
   IMAGE UPLOAD AREA
--------------------------------------- */
.file-upload-wrapper {
  border: 2px dashed #f7931a;
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  background-color: #111;
  transition: border-color 0.3s ease, background-color 0.3s ease;
  cursor: pointer;
}

.file-upload-wrapper:hover {
  border-color: #ffa73a;
  background-color: #1a1a1a;
}

.file-upload-wrapper input[type="file"] {
  display: none;
}

.file-upload-text {
  font-size: 14px;
  color: #aaa;
}

.upload-status {
  font-size: 0.9rem;
  margin-top: 6px;
  color: #888;
  font-style: italic;
}

.upload-status.success {
  color: #4caf50;
  font-weight: bold;
}

.upload-status.error {
  color: #ff4d4d;
  font-weight: bold;
}

/* ---------------------------------------
   SELECT DROPDOWN
--------------------------------------- */
select {
  background-color: #111;
  color: #f7931a;
  border: 1px solid #f7931a;
  font-size: 1rem;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23f7931a'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
  padding-right: 36px;
}

/* ---------------------------------------
   VIGENÈRE KEYWORD INPUT
--------------------------------------- */
.vigenere-keyword {
  border: 1px solid #f7931a;
  background-color: #111;
  color: #fff;
  font-size: 16px;
  padding: 10px;
  border-radius: 5px;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.vigenere-keyword:focus {
  outline: none;
  border-color: #ffa73a;
  box-shadow: 0 0 6px rgba(247, 147, 26, 0.5);
}

#vigenereOptions label {
  color: #f7931a;
}

/* ---------------------------------------
   BUTTONS
--------------------------------------- */
button {
  margin-top: 20px;
  background: #f7931a;
  color: #0c0c0c;
  font-weight: bold;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.3s ease;
}
button:hover {
  background: #ffa73a;
}

/* ---------------------------------------
   OUTPUT BOX
--------------------------------------- */
.output-box {
  width: 100%;
  background: #0c0c0c;
  color: #fff;
  border: 1px solid #4d4d4d;
  border-radius: 5px;
  padding: 10px;
  font-size: 14px;
  line-height: 1.4;
  resize: vertical;
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
  margin-top: 15px;
}

/* ---------------------------------------
   CANVAS & PREVIEW STYLES
--------------------------------------- */
.pixel-preview-wrapper {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  width: 100%;
  overflow: hidden;
  margin: 30px 0;
  position: relative;
}

.pixel-preview-scaler {
  display: inline-block;
  transform-origin: top center;
  margin: 0 auto;
  max-width: 100%;
}

canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border: none;
}

#previewCanvas {
  display: block;
  image-rendering: pixelated;
}

/* ---------------------------------------
   TOOLTIP
--------------------------------------- */
.tooltip {
  position: absolute;
  background: #ffffff;
  color: #0c0c0c;
  font-size: 12px;
  padding: 4px 6px;
  border-radius: 4px;
  pointer-events: none;
  white-space: nowrap;
  z-index: 10;
}
.tooltip.hidden {
  display: none;
}

/* ---------------------------------------
   CAESAR / VIGENERE CONDITIONAL FIELDS
--------------------------------------- */
.hidden { display: none !important; }

/* ===== Mobile-friendly helpers ===== */

/* Fluid typography without blowing up on desktop */
:root{
  --step--1: clamp(12px, 2.5vw, 14px);
  --step-0:  clamp(14px, 2.8vw, 16px);
  --step-1:  clamp(16px, 3.2vw, 18px);
  --step-2:  clamp(18px, 3.6vw, 22px);
  --step-3:  clamp(20px, 4.4vw, 28px);
}
html, body { font-size: var(--step-0); }

/* Page container */
.container, main, .page {
  max-width: 1000px;
  margin: 0 auto;
  padding: 16px;
}

/* Make images and canvas adapt to width */
img, svg, video, canvas {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Preserve crisp pixels for your cipher images */
canvas, .pixel {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Inputs & buttons: comfy tap targets */
button, .btn, input[type="text"], input[type="search"], input[type="number"], select, textarea {
  min-height: 44px;      /* Apple HIG */
  padding: 10px 14px;
  font-size: var(--step-0);
  width: 100%;
  box-sizing: border-box;
}

/* Inline actions on wider screens */
.actions, .controls, .search-row {
  display: grid;
  gap: 12px;
}
@media (min-width: 640px){
  .actions, .controls, .search-row {
    grid-template-columns: 1fr auto; /* input grows, button fits */
    align-items: center;
  }
}

/* Card/grid layout that collapses gracefully */
.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
}
@media (min-width: 640px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 960px) { .grid { grid-template-columns: repeat(3, 1fr); } }

/* Flex rows that stack on mobile */
.row, .toolbar, .header-row {
  display: flex; gap: 12px; flex-wrap: wrap;
}
.stack-on-mobile { display: flex; gap: 12px; }
@media (max-width: 639px){
  .stack-on-mobile { flex-direction: column; }
}

/* Headings scale a bit */
h1 { font-size: var(--step-3); margin: 0 0 12px; }
h2 { font-size: var(--step-2); margin: 16px 0 8px; }
h3 { font-size: var(--step-1); margin: 12px 0 6px; }

/* Tables: scroll instead of overflowing */
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }

/* Footer spacing on small screens */
footer { padding: 24px 16px; }

/* ===== Mobile overflow guardrails ===== */

/* 1) Make sizing predictable and stop any child from growing past the viewport */
*, *::before, *::after { box-sizing: border-box; min-width: 0; }
html, body { width: 100%; overflow-x: hidden; }

/* 2) Containers must never exceed the viewport width */
.page, main, .container, section, .card, .panel {
  max-width: 100vw;
}

/* 3) Form controls should shrink within their parent */
input, select, textarea, button {
  width: 100%;
  max-width: 100%;
  display: block;
}

/* 4) Any rows that were flex-ing too wide will wrap on phones */
.row, .toolbar, .controls {
  display: flex; gap: 12px; flex-wrap: wrap;
}

/* 5) Long unbroken text (e.g., hex or long filenames) won’t force overflow */
pre, code, .mono, .hash, .hex, .path {
  white-space: pre-wrap;
  word-break: break-word;
}

/* 6) Keep big shadows from creating a phantom scrollbar */
.site-header, .btn, .card {
  overflow: hidden;
}

/* 7) Safe, fluid container padding */
.container {
  width: 100%;
  margin: 0 auto;
  max-width: 960px;
  padding: 16px;
}
@media (min-width: 768px){
  .container { padding: 24px; }
}

/* --- Metadata card --- */
.meta-card{
  margin-top: 20px;
  background: #17191d;
  border: 1px solid #2a2f37;
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 18px 40px rgba(0,0,0,.35);
}

.meta-title{
  margin: 0 0 8px 0;
  color: #f7931a;
  font-size: 18px;
}

.meta-sub{
  margin: 0 0 10px 0;
  color: #a6aab1;
}

.meta-code{
  width: 100%;
  resize: vertical;
  background: #0f1114;
  color: #e8e8e8;
  border: 1px solid #2a2f37;
  border-radius: 10px;
  padding: 12px;
  line-height: 1.45;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas,
               "Liberation Mono", "Courier New", monospace;
  white-space: pre;
  overflow: auto;
}

.meta-code:focus{
  outline: 2px solid #f7931a55;
  border-color: #f7931a;
}

.meta-hint{
  margin: 8px 0 0 0;
  color: #8f949c;
  font-size: 0.95em;
}

/* Visually-hidden helper for accessibility */
.sr-only{
  position: absolute !important;
  height: 1px; width: 1px;
  overflow: hidden; clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap; border: 0; padding: 0; margin: -1px;
}

/* Mobile spacing tweak */
@media (max-width: 480px){
  .meta-card{ padding: 14px; }
  .meta-title{ font-size: 16px; }
}

/* Color picker styling (works on WebKit & Firefox) */
.color-accent{
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  max-width: auto;
  height: 32px;
  padding: 0;
  border: 1px solid #4d4d4d;
  border-radius: 5px;
  background: #000;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.03);
  cursor: pointer;
}

/* Focus/hover states */
.color-accent:hover { border-color: #3a404a; }
.color-accent:focus { outline: 2px solid #f7931a55; border-color: #f7931a; }

/* WebKit: remove internal padding & swatch border */
.color-accent::-webkit-color-swatch-wrapper { padding: 0; }
.color-accent::-webkit-color-swatch {
  border: none;
  border-radius: 5px;
}

/* Firefox: style the swatch */
.color-accent::-moz-color-swatch {
  border: none;
  border-radius: 5px;
}
