/* ===== Time Waster Pro web — system.css retro styling ===== */
/* Ported from extension/firefox/system.css (System 7 Mac look). */

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

/* ===== Font Faces ===== */
@font-face {
  font-family: Chicago;
  src: url(fonts/ChicagoFLF.woff2) format("woff2"),
       url(fonts/ChicagoFLF.ttf) format("truetype");
  font-display: swap;
}

@font-face {
  font-family: Monaco;
  src: url(fonts/Monaco.woff2) format("woff2"),
       url(fonts/Monaco.ttf) format("truetype");
  font-display: swap;
}

@font-face {
  font-family: Chicago_12;
  src: url(fonts/ChiKareGo2.woff2) format("woff2"),
       url(fonts/ChiKareGo2.ttf) format("truetype");
  font-display: swap;
}

/* ===== Scrollbars ===== */
* {
  scrollbar-width: thin;
  scrollbar-color: #fff #c0c0c0;
}

::-webkit-scrollbar {
  background-color: #fff;
  width: 22px;
}

::-webkit-scrollbar-track {
  background: linear-gradient(45deg, #000 25%, transparent 0, transparent 75%, #000 0, #000),
              linear-gradient(45deg, #000 25%, transparent 0, transparent 75%, #000 0, #000);
  background-color: #fff;
  background-position: 0 0, 2px 2px;
  background-size: 4px 4px;
  border-left: 3px solid #000;
  width: 10px;
}

::-webkit-scrollbar-thumb {
  background-color: #fff;
  border: 2px solid #000;
  border-right: none;
  box-sizing: content-box;
  width: 20px;
}

/* ===== Base ===== */
body {
  margin: 0;
  padding: 0 0 env(safe-area-inset-bottom, 0px);
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: #c0c0c0;
  font-family: Chicago_12, Chicago, Geneva, sans-serif;
  font-size: 14px;
  font-weight: normal;
  color: #000;
  line-height: 1.4;
  overscroll-behavior: none;
}

a {
  color: #000;
  text-decoration: underline;
}

h1 {
  font-family: Chicago, Chicago_12, Geneva, sans-serif;
  font-weight: bold;
  font-size: 1.4em;
  text-align: center;
  margin: 1rem 0;
}

h1 small {
  font-size: 0.7em;
  font-weight: normal;
}

h2 {
  font-family: Chicago, Chicago_12, Geneva, sans-serif;
  font-weight: bold;
  font-size: 1.1em;
  margin-top: 0;
}

.hidden { display: none !important; }

/* ===== Buttons ===== */
button,
.buttonlike {
  touch-action: manipulation; /* no double-tap zoom / 300ms tap delay */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

button {
  background: #fff;
  border: 1.5px solid #000;
  color: #000;
  cursor: pointer;
  font-family: Chicago_12, Chicago, Geneva, sans-serif;
  font-size: 14px;
  font-weight: bold;
  line-height: 1.4;
  min-height: 20px;
  padding: 2px 20px;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (hover: hover) {
  button:hover { background: #f0f0f0; }
}

button:active {
  background: #000;
  border-radius: 6px;
  color: #fff;
}

button.primary {
  border-width: 3px;
}

button.primary:disabled {
  color: #b6b7b8;
  cursor: wait;
}

.link-btn {
  background: none;
  border: none;
  color: #000;
  text-decoration: underline;
  font-weight: normal;
  padding: 2px 4px;
}

.link-btn:active {
  background: #000;
  border-radius: 0;
}

.buttonlike {
  display: inline-block;
  background: #fff;
  border: 1.5px solid #000;
  color: #000;
  cursor: pointer;
  font-family: Chicago_12, Chicago, Geneva, sans-serif;
  font-size: 14px;
  font-weight: bold;
  line-height: 1.4;
  padding: 2px 20px;
  text-align: center;
  text-decoration: none;
}

.buttonlike:active {
  background: #000;
  border-radius: 6px;
  color: #fff;
}

/* ===== Touch devices ===== */
@media (pointer: coarse) {
  button,
  .buttonlike {
    min-height: 44px;
  }
  .dialog-actions button {
    flex: 1;
  }
}

/* ===== Form Elements ===== */
input, select {
  border: 1.5px solid #000;
  font-family: Chicago_12, Chicago, Geneva, sans-serif;
  /* 16px: iOS Safari auto-zooms the viewport into any smaller input on focus */
  font-size: 16px;
  font-weight: normal;
  line-height: 1.4;
  padding: 4px 5px;
  color: #000;
  background: #fff;
}

input:focus {
  outline: none;
}

input:focus-visible,
select:focus-visible {
  background: #000;
  color: #fff;
}

select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg width='17' height='17' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='%23fff' d='M0 0h17v17H0z'/%3E%3Cpath fill='%23000' d='M2 5h13v1H2zM4 7h9v1H4zM5 8h7v1H5zM6 9h5v1H6zM7 10h3v1H7zM8 11h1v1H8zM3 6h11v1H3z'/%3E%3C/svg%3E");
  background-position: top 2px right 2px;
  background-repeat: no-repeat;
  box-shadow: 2px 2px 0 -1px #000;
  padding-left: 20px;
  width: 100%;
}

/* ===== Screens ===== */
.screen { display: none; flex: 1; }
.screen.active { display: flex; }

#loginScreen, #registerScreen, #forgotScreen, #resetScreen {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.card {
  background: #fff;
  border: 1px solid #000;
  box-shadow: 2px 2px #000;
  padding: 13px;
  width: min(360px, 90vw);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.card label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
}

/* ===== Messages ===== */
.msg {
  min-height: 1.2em;
  margin: 0;
}

.msg.error,
.msg.success {
  padding: 6px;
  border: 1px solid #000;
  text-align: center;
  font-size: 12px;
  background: #fff;
  color: #000;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* ===== Top Bar ===== */
#topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  padding-top: calc(6px + env(safe-area-inset-top, 0px));
  padding-left: calc(10px + env(safe-area-inset-left, 0px));
  padding-right: calc(10px + env(safe-area-inset-right, 0px));
  background: #fff;
  border-bottom: 1px solid #000;
}

#userInfo {
  background: #fff;
  border: 1px solid #000;
  padding: 4px 8px;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== Stumble Bar ===== */
#stumbleScreen { flex-direction: column; position: relative; }

#stumbleBar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 6px 10px;
  /* reserve room for the edge-docked collapse tab */
  padding-right: calc(60px + env(safe-area-inset-right, 0px));
  padding-left: calc(10px + env(safe-area-inset-left, 0px));
  background: #fff;
  border-bottom: 1px solid #000;
  flex-wrap: wrap;
}

#stumbleBtn {
  font-size: 14px;
  min-height: 44px;
  padding: 8px 24px;
  border-width: 3px;
}

#siteInfo {
  flex: 1;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#siteInfo strong {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The site title doubles as the open-in-new-tab link (the raw URL is
   intentionally not shown; sharing/copying is covered by the share button). */
#siteUrl {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-decoration: none;
}

/* Explicit "you are leaving our app" marker for the framed site's domain.
   Sits in app chrome the iframe can never overlay, so a lookalike login
   inside the frame can't hide which domain is actually being viewed. */
.domain-badge {
  font-size: 11px;
  color: #444;
  background: #e8e8e8;
  border: 1px dashed #000;
  padding: 1px 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#actionDock {
  position: fixed;
  right: calc(8px + env(safe-area-inset-right, 0px));
  bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 6;
}

#actionDock button,
#barRestore {
  min-width: 48px;
  min-height: 48px;
  font-size: 18px;
  box-shadow: 2px 2px #000;
}

/* Stumble is the primary dock action: inverted, top of the stack. */
#actionDock #stumbleBtn {
  font-size: 20px;
  padding: 4px 8px;
  background: #000;
  color: #fff;
}

#actionDock #stumbleBtn:active {
  background: #fff;
  color: #000;
}

#actionDock svg {
  display: block;
  margin: 0 auto;
  pointer-events: none;
}

#actionMenu {
  position: fixed;
  right: calc(64px + env(safe-area-inset-right, 0px));
  bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #fff;
  border: 1.5px solid #000;
  box-shadow: 2px 2px #000;
  padding: 6px;
  z-index: 6;
}

#actionMenu button {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-start;
  min-width: 170px;
  min-height: 44px;
  text-align: left;
  font-size: 14px;
}

/* Collapse tab: docked to the right edge of the stumble bar, arrow points
 * at the edge. Restore tab sits at the same edge once the bar is hidden. */
#barCollapse {
  position: absolute;
  right: calc(4px + env(safe-area-inset-right, 0px));
  top: 50%;
  transform: translateY(-50%);
  min-width: 44px;
  min-height: 44px;
  font-size: 18px;
}

#barRestore {
  position: absolute;
  top: 4px;
  right: calc(4px + env(safe-area-inset-right, 0px));
  z-index: 5;
  min-width: 44px;
  min-height: 44px;
  font-size: 18px;
  box-shadow: 2px 2px #000;
}

/* ===== Frame ===== */
#frameWrap {
  position: relative;
  flex: 1;
  background: #fff;
  border: 1px solid #000;
  margin: 8px;
  margin-left: calc(8px + env(safe-area-inset-left, 0px));
  margin-right: calc(8px + env(safe-area-inset-right, 0px));
}

@media (max-width: 640px) {
  #frameWrap {
    margin: 4px;
    margin-left: calc(4px + env(safe-area-inset-left, 0px));
    margin-right: calc(4px + env(safe-area-inset-right, 0px));
  }
}

#siteFrame,
#preloadFrame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
}

#frameBlocked {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  text-align: center;
  padding: 1rem;
}

#frameBlocked p {
  background: #fff;
  border: 1px solid #000;
  box-shadow: 2px 2px #000;
  padding: 13px;
  max-width: 40ch;
}

#frameSlow {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1.5px solid #000;
  box-shadow: 2px 2px #000;
  padding: 4px 8px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 2;
}

/* ===== Dialogs ===== */
dialog {
  background: #fff;
  border: 2px solid #000;
  box-shadow: 2px 2px #000;
  padding: 10px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  min-width: min(400px, 90vw);
  max-width: 94vw;
  max-height: 85vh;
  max-height: 85dvh;
  overflow-y: auto;
}

dialog::backdrop { background: rgba(0, 0, 0, 0.35); }

dialog label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  margin-bottom: 8px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 1rem;
}

.dialog-actions.tabs {
  justify-content: center;
  margin: 0 0 8px;
}

.dialog-actions.tabs button {
  flex: 1;
  font-size: 12px;
  min-width: 0;
}

.dialog-actions.tabs button.primary {
  background: #000;
  border-radius: 0;
  color: #fff;
}

/* ===== Leaderboard / History Lists ===== */
#leaderboardList,
#historyList {
  background: #fff;
  border: 1px solid #000;
  padding: 6px;
  margin-bottom: 8px;
  max-height: 50vh;
  overflow-y: auto;
  overflow-x: hidden;
}

.history-entry {
  padding: 6px 4px;
  margin-bottom: 4px;
  border-bottom: 1px dotted #000;
  font-size: 12px;
  line-height: 1.4;
  min-width: 0;
  overflow: hidden;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.history-entry a {
  word-break: break-all;
}

#rankBadge {
  font-weight: bold;
}

/* ===== PWA / iOS ===== */
#iosHint {
  background: #fff;
  border: 1.5px solid #000;
  box-shadow: 2px 2px #000;
  padding: 8px 10px;
  width: min(360px, 90vw);
  font-size: 12px;
  line-height: 1.4;
}

/* ===== Desktop sizing ===== */
/* Mobile sizes are the baseline; scale up chrome text on mouse/trackpad. */
@media (hover: hover) and (pointer: fine) {
  body {
    font-size: 16px;
  }

  #userInfo {
    font-size: 16px;
  }

  .link-btn {
    font-size: 16px;
  }

  #siteInfo strong {
    font-size: 18px;
  }

  #actionDock button,
  #barRestore,
  #barCollapse {
    min-width: 56px;
    min-height: 56px;
    font-size: 22px;
  }

  #actionDock #stumbleBtn {
    font-size: 34px;
    padding: 2px 6px;
  }

  .msg,
  .msg.error,
  .msg.success {
    font-size: 18px;
  }

  #actionDock svg {
    width: 24px;
    height: 24px;
  }
}

/* Rated state: chosen face inverts, both faces disabled until next stumble. */
#actionDock button.rated {
  background: #000;
  border-color: #000;
}

#actionDock button.rated svg path {
  fill: #fff;
}

#actionDock button:disabled {
  cursor: default;
  color: #000;
  background: #fff;
}

#actionDock button.rated:disabled {
  background: #000;
}

/* ===== Firefox focus cleanup (as in extension) ===== */
::-moz-focus-inner {
  border: 0;
  padding: 0;
}

button:focus-visible {
  outline: 2px solid #000;
  outline-offset: 2px;
}
