/* Reset default styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Arial', sans-serif;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Light mode (default) */
body {
  background-color: #ffffff;
  color: #000000;
  cursor: default;
  text-align: center;
}

/* Centering lives on a wrapper, not on body: in-app browsers (Instagram, Facebook) inject
   their own elements into body, which would otherwise become flex siblings and squeeze the page */
.page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px 0 20px 0;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color 0.3s;
}

.container {
  width: 90%;
  max-width: 450px;
}

.profile-pic {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 15px;
  border: 2px solid black;
}

.name {
  font-size: 28px;
  font-weight: bold;
  margin: 10px 0;
}

.description {
  font-size: 16px;
  margin-bottom: 30px;
  line-height: 1.6;
  color: #555;
}

.links {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-top: 10px;
}

.link-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background-color: #f0f0f0;
  color: black;
  padding: 15px;
  border-radius: 8px;
  font-size: 18px;
  font-weight: 500;
  transition: background-color 0.3s, transform 0.2s;
}

@media (hover: hover) {
  .link-button:hover {
    background-color: #e0e0e0;
    transform: scale(1.05);
  }
}

/* Touch devices get press feedback instead of a hover state that sticks after a tap */
.link-button:active {
  transform: scale(0.98);
}

/* Link group: a button that opens a chooser dialog (e.g. multiple accounts) */
button.link-button {
  width: 100%;
  border: none;
  cursor: pointer;
  text-align: left;
}

.link-dialog {
  margin: auto;
  padding: 0;
  width: calc(100% - 40px);
  max-width: 360px;
  border: none;
  border-radius: 14px;
  background-color: #ffffff;
  color: #000000;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}

.link-dialog::backdrop {
  background-color: rgba(0, 0, 0, 0.45);
}

.link-dialog[open] {
  animation: link-dialog-in 0.2s ease-out;
}

.link-dialog[open]::backdrop {
  animation: link-dialog-fade 0.2s ease-out;
}

@keyframes link-dialog-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
}

@keyframes link-dialog-fade {
  from {
    opacity: 0;
  }
}

:root:has(.link-dialog[open]) {
  overflow: hidden;
}

.link-dialog-body {
  padding: 20px;
}

/* The dialog body takes initial focus so no option looks pre-selected */
.link-dialog-body:focus {
  outline: none;
}

.link-dialog-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 16px;
  font-size: 18px;
}

.link-dialog-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.link-dialog-option {
  display: flex;
  align-items: center;
  padding: 14px 15px;
  border-radius: 8px;
  background-color: #f0f0f0;
  font-size: 16px;
  font-weight: 500;
  text-align: left;
  transition: background-color 0.3s;
}

@media (hover: hover) {
  .link-dialog-option:hover {
    background-color: #e0e0e0;
  }
}

.link-dialog-external {
  display: inline-block;
  margin-left: auto;
  font-size: 12px;
  opacity: 0.5;
}

.link-dialog-cancel {
  width: 100%;
  margin-top: 12px;
  padding: 12px;
  border: none;
  border-radius: 8px;
  background: none;
  color: #555;
  font-size: 16px;
  cursor: pointer;
}

@media (hover: hover) {
  .link-dialog-cancel:hover {
    color: #000;
  }
}

.link-dialog-option:focus-visible,
.link-dialog-cancel:focus-visible {
  outline: 2px solid #111;
  outline-offset: 2px;
}

/* Phones: slide up from the bottom as an action sheet */
@media (max-width: 600px) {
  .link-dialog {
    margin: auto auto 0;
    width: 100%;
    max-width: 100%;
    border-radius: 16px 16px 0 0;
  }

  .link-dialog-body {
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }

  .link-dialog[open] {
    animation-name: link-dialog-sheet-in;
    animation-duration: 0.25s;
  }

  @keyframes link-dialog-sheet-in {
    from {
      transform: translateY(100%);
    }
  }
}

/* Font Awesome icons are inlined as SVG at build time (scaffold.rb); base sizing from FA */
.svg-inline--fa {
  display: inline-block;
  box-sizing: content-box;
  height: 1em;
  overflow: visible;
  vertical-align: -0.125em;
}

svg.custom-icon {
  fill: currentColor;
  width: 1em;
  height: 1em;
}

/* Fixed-width icon column so every label starts at the same x (like fa-fw) */
.link-button > i,
.link-button > svg {
  display: inline-flex;
  justify-content: center;
  flex: 0 0 1.25em;
  width: 1.25em;
}

/* Optical size: the outline Instagram glyph reads smaller than the filled icons */
.link-button .fa-instagram,
.link-dialog-title .fa-instagram {
  transform: scale(1.15);
}

.footer {
  margin-top: 40px;
  font-size: 14px;
  color: #777;
}

.button-container {
  display: flex;
  align-items: center;
  justify-content: center;
}

.button-group {
  display: flex;
  gap: 15px;
  margin-top: 25px;
}

.icon-button {
  border: none;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s;
  background: none;
  color: black;
}

.icon-button i {
  font-size: 24px;
}

@media (hover: hover) {
  .icon-button:hover {
    transform: scale(1.1);
    color: #666;
  }
}

.icon-button:active {
  transform: scale(0.95);
}

.link-button:focus-visible,
.icon-button:focus-visible {
  outline: 2px solid #111;
  outline-offset: 3px;
}

.link-button-text {
  font-size: 14px;
  color: #777;
}

.copyright {
  margin-top: 15px;
  font-size: 12px;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  body {
    background-color: #0d1117;
    color: white;
  }

  a {
    color: white;
  }

  .profile-pic {
    border-color: white;
  }

  .description {
    color: #c9d1d9;
  }

  .link-button {
    background-color: #21262d;
    color: white;
  }

  @media (hover: hover) {
    .link-button:hover {
      background-color: #30363d;
    }
  }

  .link-dialog {
    background-color: #161b22;
    color: white;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  }

  .link-dialog::backdrop {
    background-color: rgba(0, 0, 0, 0.6);
  }

  .link-dialog-option {
    background-color: #21262d;
  }

  @media (hover: hover) {
    .link-dialog-option:hover {
      background-color: #30363d;
    }
  }

  .link-dialog-cancel {
    color: #8b949e;
  }

  @media (hover: hover) {
    .link-dialog-cancel:hover {
      color: white;
    }
  }

  .link-dialog-option:focus-visible,
  .link-dialog-cancel:focus-visible {
    outline-color: #e6edf3;
  }

  .icon-button {
    color: white;
  }

  .footer {
    color: #8b949e;
  }

  .link-button-text {
    color: #8b949e;
  }

  .link-button:focus-visible,
  .icon-button:focus-visible {
    outline-color: #e6edf3;
  }
}

/* Entrance: elements fade up one after another on load. `backwards` fill only holds the
   start state during the delay, so hover/press transforms still work after the animation */
.profile-pic,
.name,
.description,
.link-button,
.icon-button,
.footer {
  animation: enter 0.6s cubic-bezier(0.22, 1, 0.36, 1) backwards;
  animation-delay: calc(var(--i, 0) * 45ms + 80ms);
}

.profile-pic {
  animation-name: enter-pop;
}

.name {
  --i: 1;
}

.description {
  --i: 2;
}

@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

@keyframes enter-pop {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
}

/* Installed app (PWA): keep the root black like the launch screen and fade the page in,
   so launch -> page is a smooth crossfade and a mis-sized first frame on cold launch isn't visible */
@media (display-mode: standalone) {
  html {
    background-color: #000000;
  }

  body {
    animation: page-in 0.35s ease-out both;
  }

  @keyframes page-in {
    from {
      opacity: 0;
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}