/* ==========================================================================
   ASK MODE — Brutalist Terminal Interface
   Monochrome · Machine-like · Day/Night Auto Theme
   ========================================================================== */

:root {
  --ask-bg: #fafafa;
  --ask-fg: #0a0a0a;
  --ask-muted: rgba(10, 10, 10, 0.5);
  --ask-dim: rgba(10, 10, 10, 0.25);
  --ask-selection: rgba(10, 10, 10, 0.1);
}

/* Night mode (6pm - 6am) applied via JS */
.ask-night {
  --ask-bg: #0a0a0a;
  --ask-fg: #e8e8e8;
  --ask-muted: rgba(232, 232, 232, 0.5);
  --ask-dim: rgba(232, 232, 232, 0.25);
  --ask-selection: rgba(232, 232, 232, 0.12);
}

/* --------------------------------------------------------------------------
   Floating Toggle Button (bottom-right)
   -------------------------------------------------------------------------- */
.ask-toggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;

  padding: 8px 12px;
  border: none;
  border-radius: 0;
  background: transparent;
  cursor: pointer;

  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 400;
  font-size: 9px;
  line-height: 1;
  letter-spacing: 0.15em;
  text-transform: uppercase;

  transition: color 0.5s ease, opacity 0.2s ease;
}

/* Light text on dark backgrounds */
body.on-dark .ask-toggle {
  color: rgba(255, 255, 255, 0.6);
}

body.on-dark .ask-toggle:hover {
  color: rgba(255, 255, 255, 0.9);
}

/* Dark text on light backgrounds */
body.on-light .ask-toggle {
  color: rgba(0, 0, 0, 0.4);
}

body.on-light .ask-toggle:hover {
  color: rgba(0, 0, 0, 0.7);
}

.ask-toggle:focus-visible {
  outline: 1px solid currentColor;
  outline-offset: 2px;
}

/* Hide when ask mode is open */
body.ask-mode .ask-toggle {
  display: none;
}

@media (max-width: 600px) {
  .ask-toggle {
    bottom: 12px;
    right: 12px;
    font-size: 8px;
  }
}

/* --------------------------------------------------------------------------
   Container
   -------------------------------------------------------------------------- */
.ask-container[hidden] {
  display: none !important;
  visibility: hidden;
  width: 0;
  height: 0;
  overflow: hidden;
}

.ask-container {
  max-width: 100vw;
}

body.ask-mode {
  overflow: hidden !important;
  touch-action: none;
  width: 100%;
  max-width: 100vw;
}

body.ask-mode > header,
body.ask-mode > main,
body.ask-mode > noscript {
  display: none !important;
}

body.ask-mode .ask-container {
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0;
  z-index: 9999;
  overflow: hidden;
  touch-action: pan-y;
  background: var(--ask-bg);
  color: var(--ask-fg);
}

/* --------------------------------------------------------------------------
   Text Area (Terminal)
   -------------------------------------------------------------------------- */
.ask-field {
  flex: 1;
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  resize: none;
  overflow-x: hidden;
  overflow-y: auto;
  word-wrap: break-word;
  overflow-wrap: break-word;
  touch-action: pan-y;

  background: var(--ask-bg);
  color: var(--ask-fg);
  caret-color: var(--ask-fg);
  animation: cursor-blink 1.2s ease-in-out infinite;

  padding: 20px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-weight: 400;
  font-size: 15px;
  line-height: 1.7;
  letter-spacing: 0.01em;
  tab-size: 2;
  white-space: pre-wrap;

  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

@keyframes cursor-blink {
  0%, 100% { caret-color: var(--ask-fg); }
  50% { caret-color: transparent; }
}

.ask-field::selection {
  background: var(--ask-selection);
}

.ask-field::placeholder {
  color: var(--ask-dim);
}

.ask-field:read-only {
  opacity: 0.8;
}

/* Scrollbar */
.ask-field {
  scrollbar-width: thin;
  scrollbar-color: var(--ask-dim) transparent;
}

.ask-field::-webkit-scrollbar {
  width: 6px;
}

.ask-field::-webkit-scrollbar-track {
  background: transparent;
}

.ask-field::-webkit-scrollbar-thumb {
  background: var(--ask-dim);
  border-radius: 0;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (min-width: 768px) {
  .ask-field {
    padding: 40px;
    font-size: 16px;
  }
}

@media (min-width: 1200px) {
  .ask-field {
    padding: 80px;
    font-size: 17px;
    line-height: 1.75;
  }
}

/* --------------------------------------------------------------------------
   Print: Hide
   -------------------------------------------------------------------------- */
@media print {
  .ask-container,
  .ask-toggle {
    display: none !important;
  }
}

/* --------------------------------------------------------------------------
   Mobile: Extra right padding for text breathing room
   -------------------------------------------------------------------------- */
@media (max-width: 767px) {
  .ask-field {
    padding: 16px 28px 16px 16px !important;
  }
}
