=== AddonLogic Dark Mode Toggle ===
Contributors: snehalpancholi
Tags: dark mode, dark theme, night mode, accessibility, toggle
Requires at least: 6.0
Tested up to: 6.7
Requires PHP: 8.1
Stable tag: 1.0.0
License: GPL-2.0+
License URI: https://www.gnu.org/licenses/gpl-2.0.html

A frontend dark-mode switch that applies a dark stylesheet and remembers the visitor's choice via localStorage.

== Description ==

AddonLogic Dark Mode Toggle adds a smart floating dark mode button to your WordPress site. Visitors can switch between light and dark themes with one click, and their choice is remembered across all visits using localStorage — no cookies, no server round-trips.

**Key Features:**

* Floating toggle button in four possible screen positions (bottom-right, bottom-left, top-right, top-left)
* Moon icon in light mode, Sun icon in dark mode — clear, accessible SVG icons
* Automatic OS dark mode detection via `prefers-color-scheme` media query
* Visitor's manual choice always takes priority over OS setting
* Comprehensive dark stylesheet covering body, typography, links, tables, forms, navigation, widgets, Gutenberg blocks, and comments
* Custom CSS override textarea — add theme-specific rules scoped to `html.dark-mode {}`
* Visibility control — show toggle on all pages, posts only, pages only, or all singular content
* Zero jQuery, vanilla ES6 JavaScript
* Flash-of-unstyled-content (FOUC) prevention: dark class applied before first paint
* Translation-ready with full gettext support
* Lightweight: tiny JS and CSS footprint

**Settings Page:**

Navigate to Settings → Dark Mode Toggle to configure button position, OS detection, visibility, and custom CSS overrides.

== Installation ==

1. Upload the `dark-mode-toggle` folder to `/wp-content/plugins/`
2. Activate the plugin through the Plugins menu in WordPress
3. Go to **Settings → Dark Mode Toggle** to configure your preferences
4. The toggle button will automatically appear on your frontend pages

== Frequently Asked Questions ==

= Does it work with page builders? =
Yes. The dark mode styles target standard HTML elements and WordPress structural classes. For page builder-specific backgrounds, use the Custom CSS override field in the settings.

= Will the toggle appear on every page? =
By default, yes. You can restrict it to posts only, pages only, or all singular content (posts + pages + custom post types) in the settings.

= Does it use cookies? =
No. The visitor's preference is stored in the browser's localStorage. It does not set any cookies, making it GDPR-friendly out of the box.

= What happens if JavaScript is disabled? =
The site renders in light mode as normal. The toggle button is injected via PHP into the footer, but without JS it has no click handler, so it remains inert.

= Can I customise the dark mode colours? =
Yes. The custom CSS override textarea in the settings page lets you add rules that are automatically scoped to `html.dark-mode { }`. This is the recommended way to handle theme-specific overrides.

= Does it detect the user's OS dark mode setting? =
Yes. When "Auto-Detect OS Preference" is enabled (the default), the plugin uses the `prefers-color-scheme: dark` media query to apply dark mode automatically. If the visitor clicks the toggle, their manual choice overrides the OS setting for all subsequent visits.

= Can I remove the visitor's saved preference? =
Visitors can clear their own localStorage. There is no admin-side mechanism to reset individual visitor preferences since they are stored client-side only.

== Screenshots ==

1. Settings page — configure button position, OS detection, and custom CSS
2. Frontend light mode — moon icon toggle button in bottom-right corner
3. Frontend dark mode — sun icon toggle button, full dark theme applied

== Changelog ==

= 1.0.0 =
* Initial release
* Floating toggle button with four position options
* Moon/Sun SVG icons with smooth transitions
* localStorage persistence with OS preference fallback
* Comprehensive default dark stylesheet using CSS variables
* Custom CSS override textarea with automatic scoping
* Visibility control by page type
* FOUC prevention via early class application
* Full accessibility: ARIA roles, keyboard navigation, focus outlines
* Translation-ready

== Upgrade Notice ==

= 1.0.0 =
Initial release. No upgrade steps required.
